通过FB邀请朋友在Ios进行自己的应用程序



我正在iPhone中开发一个应用程序,我需要通过使用图形API在FB上发送消息来邀请朋友加入我的应用程序。我还希望当用户点击从FB邀请朋友时,我的应用会显示对话框,实际上是FB对话框,其中显示了他的所有朋友,用户可以根据自己的意愿选择朋友发送消息。感谢

您可以使用以下中的无摩擦请求来实现这一点

 NSString *to =[NSString stringWithFormat:@"%d",[[[FriendUIDArray
 objectAtIndex:index]
                                                  objectForKey:@"uid"] intValue]];
 FBFrictionlessRecipientCache *friendCache =
 [[FBFrictionlessRecipientCache alloc] init]; [friendCache
 prefetchAndCacheForSession:nil];

 NSMutableDictionary* params =   [NSMutableDictionary
 dictionaryWithObjectsAndKeys:
                                  to, @"to",
                                  nil];
 [FBWebDialogs presentRequestsDialogModallyWithSession:nil
        message:[NSString stringWithFormat:@"I’m using Nightup to find great party's 
        around me."] title:nil  parameters:params handler:^(FBWebDialogResult result,
        NSURL *resultURL, NSError *error)
        {
                                                   if (error) {
                                                       // Case A: Error launching the dialog or sending request.
                                                       NSLog(@"Error sending request.");
                                                   } else {
                                                       if (result == FBWebDialogResultDialogNotCompleted) {
                                                           // Case B: User clicked the "x" icon
                                                           NSLog(@"User canceled request.");
                                                       } else {
                                                           NSLog(@"Request Sent.");
                                                       }
         }}
        friendCache:friendCache];

如果你没有你想邀请的特定朋友的Uid,那么按照这个方法,你可以在对话框中选择朋友。

NSMutableDictionary* params =   [NSMutableDictionary dictionaryWithObjectsAndKeys:nil]; 
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
              message:[NSString stringWithFormat:@"I just smashed %d friends! Can you beat it?", nScore]
              title:nil
              parameters:params
              handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                  if (error) {
                      // Case A: Error launching the dialog or sending request.
                      NSLog(@"Error sending request.");
                  } else {
                      if (result == FBWebDialogResultDialogNotCompleted) {
                          // Case B: User clicked the "x" icon
                          NSLog(@"User canceled request.");
                      } else {
                          NSLog(@"Request Sent.");
                  }
}}];

您可以在此处找到更多详细信息

使用@"facebook.events.invite"方法从iPhone 邀请您的朋友

例如

        params = [NSDictionary dictionaryWithObjectsAndKeys:facebookEventString,@"eid",udidsString,@"uids",nil];
        [[FBRequest requestWithDelegate:self] call:@"facebook.events.invite" params:params];

相关内容

最新更新