2017-03-01 130 views
-1

Facebook已经给了我“user_likes”,“user_bithday”等的许可,但我仍然没有收到它的数据,结果总是得到空白字典。请帮我解决它。没有得到Facebook图形API响应

-(void)loginButtonClicked { 
     FBSDKLoginManager* lm = [[FBSDKLoginManager alloc] init]; 
     lm.loginBehavior = FBSDKLoginBehaviorSystemAccount; 
     [lm logInWithReadPermissions:@[@"public_profile", @"email", @"user_birthday", @"user_likes"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { 
     if (!error && !result.isCancelled) 
     { 
      [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me/likes" parameters:@{@"fields":@"id, name, first_name, last_name, picture.type(large), email, birthday, likes"}] 
      startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 
       if (!error) { 
        NSLog(@"fetched detail: %@",result); 
       } 
      }]; 
     } 

    }]; 
} 
+0

你打电话给我/喜欢API来获取所有这些细节? – kb920

+0

检查此问题http://stackoverflow.com/questions/33513630/how-to-get-email-id-of-user-using-facebook-sdk-4-7-in-ios-9/33513692#33513692 – kb920

+0

是实际上,我看到某个地方以这种方式使用它 –

回答

0

首先,您需要检查在FB图形浏览器是乌拉圭回合得到响应

https://developers.facebook.com/tools/explorer/

如果你得到这个响应,你会得到响应代码也。

玩转编码。

编辑

试试这个,它应该返回ü一些值。

> -(void)loginButtonClicked { 
>  FBSDKLoginManager* lm = [[FBSDKLoginManager alloc] init]; 
>  lm.loginBehavior = FBSDKLoginBehaviorSystemAccount; 
>  [lm logInWithReadPermissions:@[@"public_profile", @"email", @"user_birthday", @"user_likes"] fromViewController:self 
> handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { 
>   if (!error && !result.isCancelled) 
>   { 
>    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"/me" parameters:@{@"fields":@"id, name, first_name, last_name, 
> picture.type(large), email, birthday, likes"}] 
>    startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 
>     if (!error) { 
>      NSLog(@"fetched detail: %@",result); 
>     } 
>    }]; 
>   } 
> 
>  }]; } 
+0

我在FB Graph Explorer中检查过,它显示**只有在用户授予'user_birthday'权限后才能在用户对象上访问'生日'字段。** \ n并显示** email,public_profile ** in **范围**。你能告诉我如何给我的帐户授予其他权限?因为我已经在我的代码** @ [@“public_profile”,@“email”,@“user_birthday”,@“user_likes”] ** –

+0

中显示,所以错误消息非常明确。确保user_birthday权限已被授权。 – luschn

+0

@luschn我如何授权user_birthday权限?请建议。 –