0

我正在开发一个 iOS 应用程序,我想在其中检索我的 facebook 朋友并将其发送到服务器,以检查谁已经使用他们的电子邮件或电话号码使用此应用程序。一旦我得到不使用我的应用程序的朋友,我将显示“邀请”按钮向他们的电子邮件地址发送一封电子邮件,其中包含应用商店链接以下载该应用程序。

但根据 facebook 权限,我们无法检索 facebook 朋友的电子邮件地址。 任何人都可以知道如何以其他方式实现此功能吗?任何形式的帮助表示赞赏。谢谢。

4

3 回答 3

1

您无法检索 Facebook 朋友的电子邮件地址,但您可以在他们的墙上发布您想要发布的任何链接,即应用商店链接以下载该应用程序。

于 2012-12-06T05:13:08.413 回答
0

你可以看看我的这个帖子。

由于 facebook 不提供电子邮件地址,因此此解决方案背后的想法是,您可以在 AppStore 中发送邀请好友请求以及指向您的应用程序的链接。为了完成这个案例,我已经简要描述了链接中要遵循的步骤。

邀请信息可能如下所示:

我想让你试试 XYZ 游戏。这是 AppStore 中此应用程序的链接: Facebook iOS SDK - 获取好友列表

于 2013-05-21T11:24:24.210 回答
0

您可以使用以下 FB Graph API(/me/invitable_friends) 来获取非应用好友 -

// m_invitableFriends - 保存可邀请好友列表的全局数组

- (void) getAllInvitableFriends
{
    NSMutableArray *tempFriendsList =  [[NSMutableArray alloc] init];
    NSDictionary *limitParam = [NSDictionary dictionaryWithObjectsAndKeys:@"100", @"limit", nil];
    [self getAllInvitableFriendsFromFB:limitParam addInList:tempFriendsList];
}

- (void) getAllInvitableFriendsFromFB:(NSDictionary*)parameters
                            addInList:(NSMutableArray *)tempFriendsList
{
    [FBRequestConnection startWithGraphPath:@"/me/invitable_friends"
                                 parameters:parameters
                                 HTTPMethod:@"GET"
                          completionHandler:^(
                                              FBRequestConnection *connection,
                                              id result,
                                              NSError *error
                                              ) {
                              NSLog(@"error=%@",error);

                              NSLog(@"result=%@",result);

                              NSArray *friendArray = [result objectForKey:@"data"];

                              [tempFriendsList addObjectsFromArray:friendArray];

                              NSDictionary *paging = [result objectForKey:@"paging"];
                              NSString *next = nil;
                              next = [paging objectForKey:@"next"];
                              if(next != nil)
                              {
                                  NSDictionary *cursor = [paging objectForKey:@"cursors"];
                                  NSString *after = [cursor objectForKey:@"after"];
                                  //NSString *before = [cursor objectForKey:@"before"];
                                  NSDictionary *limitParam = [NSDictionary dictionaryWithObjectsAndKeys:
                                                              @"100", @"limit", after, @"after"
                                                              , nil
                                                              ];
                                  [self getAllInvitableFriendsFromFB:limitParam addInList:tempFriendsList];
                              }
                              else
                              {
                                  [self replaceGlobalListWithRecentData:tempFriendsList];
                              }
                          }];
}

- (void) replaceGlobalListWithRecentData:(NSMutableArray *)tempFriendsList
{
    // replace global from received list
    [m_invitableFriends removeAllObjects];
    [m_invitableFriends addObjectsFromArray:tempFriendsList];
    //NSLog(@"friendsList = %d", [m_invitableFriends count]);
    [tempFriendsList release];
}

邀请非应用好友 -

您将获得带有我/invitable_friends graph api返回的朋友列表的邀请令牌。您可以将这些邀请令牌与 FBWebDialogs 一起使用,向朋友发送邀请,如下所示

- (void) openFacebookFeedDialogForFriend:(NSString *)userInviteTokens {

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   userInviteTokens, @"to",
                                   nil, @"object_id",
                                   @"send", @"action_type",
                                   actionLinksStr, @"actions",
                                   nil];

    [FBWebDialogs
     presentRequestsDialogModallyWithSession:nil
     message:@"Hi friend, I am playing game. Come and play this awesome game with me."
     title:nil
     parameters:params
     handler:^(
               FBWebDialogResult result,
               NSURL *url,
               NSError *error)
     {
         if (error) {
             // Error launching the dialog or sending the request.
             NSLog(@"Error sending request : %@", error.description);
         }
         else
         {
             if (result == FBWebDialogResultDialogNotCompleted)
             {
                 // User clicked the "x" icon
                 NSLog(@"User canceled request.");
                 NSLog(@"Friend post dialog not complete, error: %@", error.description);
             }
             else
             {
                 NSDictionary *resultParams = [g_mainApp->m_appDelegate parseURLParams:[url query]];

                 if (![resultParams valueForKey:@"request"])
                 {
                     // User clicked the Cancel button
                     NSLog(@"User canceled request.");
                 }
                 else
                 {
                     NSString *requestID = [resultParams valueForKey:@"request"];

                     // here you will get the fb id of the friend you invited,
                     // you can use this id to reward the sender when receiver accepts the request

                     NSLog(@"Feed post ID: %@", requestID);
                     NSLog(@"Friend post dialog complete: %@", url);
                 }
             }
         }
     }];
}
于 2014-12-16T06:52:58.987 回答