我正在开发一个 iPhone 应用程序,如果他们已经授予我的应用程序访问他们的电子邮件的权限,我希望能够列出连接到我的应用程序并访问他们的电子邮件的用户朋友。
这是我用来打开 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 ];
// 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);
}
}];
问题是返回的电子邮件始终为空,即使对于安装了我的应用程序并授权它访问他们的电子邮件的朋友也是如此。
对此有何建议?