通过FB邀请朋友在Ios中自己申请

时间:2012-01-18 11:01:28

标签: iphone facebook-graph-api

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

2 个答案:

答案 0 :(得分:4)

您可以使用无摩擦请求执行此操作,如下所示

 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.");
                  }
}}];

您可以找到更多详情here

答案 1 :(得分:-1)

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

e.g

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