您好我已经通过我的iOS应用程序通过以下代码在Facebook上创建了一个活动
-(void) createEvent:(NSString*)eventName Eventdesc:(NSString*)eventdesc EventDate: (NSString*)eventDate{
NSURL *meurl = [NSURL URLWithString:@"https://graph.facebook.com/me/events"];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
eventName, @"name",
eventdesc, @"description",
[NSString stringWithFormat:@"%@",[NSDate date]], @"start_time",
nil];
SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:meurl
parameters:params];
merequest.account = _facebookAccount;
[merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *meDataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"event %@", meDataString);
if (!error) {
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"" message:@"Thanks for your support. Event has been created on your facebook page." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil,nil];
[alertView show];
}else{
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"" message:@"Unable to create event on facebook." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil,nil];
[alertView show];
}
}];
}
现在我想邀请朋友参加这个创建的活动。我搜索很多,但我没有得到任何有用的信息。 请帮忙。提前谢谢。
答案 0 :(得分:0)
您可以通过发出HTTP POST to /EVENT_ID/invited/USER_ID
邀请用户参加活动。您可以通过发出H TTP POST to /EVENT_ID/invited?users=USER_ID1,USER_ID2,USER_ID3
来邀请多个用户。这两个都需要create_event权限,如果邀请成功,则返回true。
答案 1 :(得分:0)
使用以下代码解决问题
- (void)inviteFriendsToEvent:(NSString *)eventID UserID:(NSMutableArray *)userID {
NSLog(@"ID=%@",[_IDArray lastObject]);
NSLog(@"Event ID:%@",_eventID);
NSData *data = [_eventID dataUsingEncoding:NSUTF8StringEncoding];
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSLog(@"Event ID:%@",[json objectForKey:@"id"]);
NSURL *meurl = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/invited/%@",[json objectForKey:@"id"],[_IDArray lastObject]]];
//@"https://graph.facebook.com/EVENT_ID/invited?users=USER_ID1,USER_ID2,USER_ID3"
SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:meurl
parameters:nil];
merequest.account = _facebookAccount;
[merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *meDataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"Data=%@",meDataString);
}];
}