ios - 在 iOS 9 中邀请 Facebook 好友

标签 ios objective-c facebook-graph-api

我在我的 iOS 应用程序中使用此代码邀请 friend

[FBWebDialogs presentRequestsDialogModallyWithSession:nil
                                              message:@"Test1"
                                                title:@"Title 1"
                                           parameters:parameters
                                              handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
 {
     if(error)
     {
         NSLog(@"Some errorr: %@", [error description]);
         UIAlertView *alrt = [[UIAlertView alloc] initWithTitle:@"Invitiation Sending Failed" message:@"Unable to send inviation at this Moment, please make sure your are connected with internet" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
         [alrt show];

     }
     else
     {
         if (![resultURL query])
         {
             return;
         }

         NSDictionary *params = [self parseURLParams:[resultURL query]];
         NSMutableArray *recipientIDs = [[NSMutableArray alloc] init] ;
         for (NSString *paramKey in params)
         {
             if ([paramKey hasPrefix:@"to["])
             {
                 [recipientIDs addObject:[params objectForKey:paramKey]];
             }
         }
         if ([params objectForKey:@"request"])
         {
             NSLog(@"Request ID: %@", [params objectForKey:@"request"]);
         }
         if ([recipientIDs count] > 0)
         {
             //[self showMessage:@"Sent request successfully."];
             //NSLog(@"Recipient ID(s): %@", recipientIDs);
             UIAlertView *alrt = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"Invitation(s) sent successfuly!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
             [alrt show];

         }

     }
 }
                                          friendCache:nil];

//示例代码2

 [FBWebDialogs
     presentRequestsDialogModallyWithSession:nil
     message:@"Yeeeeep Check my app"
     title:@"Burp War"
     parameters:nil
     handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
         if (error) {
             // Error launching the dialog or sending the request.
             NSLog(@"Error sending request.");
         } else {
             if (result == FBWebDialogResultDialogNotCompleted) {
                 // User clicked the "x" icon
                 NSLog(@"User canceled request.");
             } else {
                 // Handle the send request callback
                 NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
                 if (![urlParams valueForKey:@"request"]) {
                     // User clicked the Cancel button
                     NSLog(@"User canceled request.");
                 } else {
                     // User clicked the Send button
                     NSString *requestID = [urlParams valueForKey:@"request"];
                     NSLog(@"Request ID: %@", requestID);
                 }
             }
         }
     }];

但不幸的是,这不起作用,出现错误“游戏请求仅适用于游戏应用程序”。如何获取 friend 的电子邮件ID?提前致谢。

最佳答案

新的图形 api 仅支持游戏的用户邀请好友 https://developers.facebook.com/docs/graph-api/reference/v2.5/user/invitable_friends

https://developers.facebook.com/docs/games/services/gamerequests

Note: There is no way for apps to obtain email addresses for a user's friends.

facebook 政策声明指出这一点

How can I get facebook friends list email addresses?

How to get a facebook user's friends emails

关于ios - 在 iOS 9 中邀请 Facebook 好友,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34625031/

相关文章:

iOS 将数据从表格单元格传递到新的 View Controller

ios - UITextField 上的圆角边缘

ios - 如何禁用在历史记录中保存CallKit调用

ios - 使用 AVAudioTime 安排将来播放的音频文件

javascript - 使用 Facebook graph api 获取页面访问 token

ios - 使用 CKSubscription/CKNotificationInfo 显示通知特定消息?

java - 如何在 Vuforia(没有 Unity)中点击模型的一部分?

Objective-C 数组风格的 C 指针下标?

Android : Getting a Bitmap from a url connection (graph. facebook.com)重定向到另一个网址

android - 为什么 facebook newMeRequest 没有响应?