我正在开发一个iOS应用程序,我想在其中检索我的Facebook好友和将其发送到服务器,以检查谁已经使用他们的电子邮件或电话号码使用此应用程序。一旦我找到不使用我的应用程序的朋友,我将显示“邀请”按钮,通过应用程序商店链接向他们的电子邮件地址发送电子邮件以下载应用程序。
但根据Facebook权限,我们无法检索Facebook好友的电子邮件地址。 有谁知道我怎么能以其他方式实现这个功能? 任何形式的帮助表示赞赏。感谢。
答案 0 :(得分:1)
您无法检索Facebook好友的电子邮件地址,但您可以在他们的墙上发布您要发布的任何链接,即应用商店链接以下载该应用。
答案 1 :(得分:0)
您可以查看我的this主题。
由于facebook不提供电子邮件地址,因此提供此解决方案的理念是,您可以通过AppStore上的应用程序链接发送邀请好友请求。为了完成这个案例,我简要描述了要遵循的链接中的步骤。
邀请消息可能如下所示:
我希望你尝试XYZ游戏。这是这个的链接 在AppStore申请: Facebook iOS SDK - get friends list
答案 2 :(得分:0)
您可以使用下面的FB Graph API(/ me / invitable_friends)获取非app朋友 -
// 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图表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);
}
}
}
}];
}