我正在将我的应用升级到Facebook-iOS-SDK-4.0,但似乎我无法从FBSDKProfile
获得用户邮箱,因为它只提供用户名、用户名、用户ID等.
我正在将我的应用升级到Facebook-iOS-SDK-4.0,但似乎我无法从FBSDKProfile
获得用户邮箱,因为它只提供用户名、用户名、用户ID等.
要获取邮箱,您需要利用graph API,特别是提供用所需字段填充的参数字段.看一看Facebook的Graph API explore工具,它可以帮助找出这些查询.https://developers.facebook.com/tools/explorer
我获取邮箱的代码如下,假设您已经登录:
NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
[parameters setValue:@"id,name,email" forKey:@"fields"];
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:parameters]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result, NSError *error) {
aHandler(result, error);
}];