iOS Facebook SDK - 获取朋友的电子邮件 [英] iOS Facebook SDK - getting friends emails
问题描述
我正在开发一个iPhone应用程序,我想能够列出连接到我的应用程序的用户的朋友并访问他们的电子邮件,如果他们已经授予我的应用程序访问他们的电子邮件。 p>
这是我用来打开Facebook会话的代码:
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray * permissions = [[NSArray alloc] initWithObjects:
@email,
nil];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession * session,
FBSessionState state,
NSError * error){
[self sessionStateChanged:session
state:state
error:error];
}];
}
此外,在ViewController.m中,我使用以下代码列出朋友,并获得他们的电子邮件:
NSString * query =
[NSString stringWithFormat:@SELECT name,uid ,pic_small,birthday,proxied_email,contact_email,email FROM user WHERE is_app_user = 1 and uid IN(SELECT uid2 FROM friend where uid1 =%@)order by concat(first_name,last_name)asc,my_fb_uid];
//设置查询参数
NSDictionary * queryParam =
[NSDictionary dictionaryWithObjectsAndKeys:query,@q,nil];
//使用FQL的API请求
[FBRequestConnection startWithGraphPath:@/ fql
参数:queryParam
HTTPMethod:@GET
completedHandler:^(FBRequestConnection * connection,
id result,
NSError * error){
if(error){
NSLog(@Error:%@,[error localizedDescription]);
} else {
NSLog(@Result:%@,result);
}
}];
问题是返回的电子邮件总是为空,即使是安装我的应用程序的朋友,授权它访问他们的电子邮件。
任何建议?
从文档:
注意:应用程序无法获取用户的朋友的电子邮件地址。
电子邮件
权限仅适用于logged_in用户
I am developing an iPhone application, and I want to be able to list the user's friends who are connected to my application and access their e-mails, if they have already granted my application access to their e-mails.
This is the code I am using to open the Facebook session:
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"email",
nil];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
}
Also, in a ViewController.m, I using the following code to list the friends and get their e-mails:
NSString *query =
[NSString stringWithFormat:@"SELECT name, uid, pic_small, birthday,proxied_email, contact_email , email FROM user WHERE is_app_user = 1 and uid IN (SELECT uid2 FROM friend where uid1 = %@) order by concat(first_name,last_name) asc", my_fb_uid ];
// Set up the query parameter
NSDictionary *queryParam =
[NSDictionary dictionaryWithObjectsAndKeys:query, @"q", nil];
// Make the API request that uses FQL
[FBRequestConnection startWithGraphPath:@"/fql"
parameters:queryParam
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(@"Error: %@", [error localizedDescription]);
} else {
NSLog(@"Result: %@", result);
}
}];
The problem is that the returned e-mails are always null, even for friends who installed my application and authorized it to access their e-mails.
Any advice on this?
From the documentation:
Note: There is no way for apps to obtain email addresses for a user's friends.
The email
permission is only for the logged_in user
这篇关于iOS Facebook SDK - 获取朋友的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!