2017-03-01 98 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權限?請建議。 –