您好我被困在一个位置我无法在Facebook获得用户名。
- (void)makeRequestForUserData
{
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
if (!error)
{
// Success! Include your code to handle the results here
NSLog("%@",result);
NSString* strUserName = [result objectForKey:@"username"];
[[NSUserDefaults standardUserDefaults] setValue:strUserName forKey:FBUSER_NAME];
[[NSUserDefaults standardUserDefaults] synchronize];
}
else
{
// An error occurred, we need to handle the error
// Check out our error handling guide: https://developers.facebook.com/docs/ios/errors/
NSLog(@"Error : %@", error.description);
}
}];
}
控制台o / p
{
"first_name" = XXX;
gender = male;
id = 4454545454;
"last_name" = System;
link = "https://www.facebook.com/app_scoped_user_id/4454545454
486934488/";
locale = "en_US";
name = “XXX”;
timezone = "5.5";
"updated_time" = "2014-02-28T09:20:26+0000";
verified = 1;
}
这里我缺少用户名?这是什么原因。我已经检查了许可
NSLog(@"permissions::%@",FBSession.activeSession.permissions);
其输出如下: permissions::(
"public_profile"
)
答案 0 :(得分:0)
如果您正在进行其他设置,这将有效
[[FBRequest requestForMe] startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary<FBGraphUser> *user,
NSError *error) {
if (!error) {
NSDictionary *userData = user;
}