2017-01-27 11 views
0

Facebook SDK経由でユーザーの情報を取得するのが苦労しています。Facebookのユーザー情報(誕生日、仕事、教育)を取得できません

私は誕生日、仕事、教育を受けようとしています。私はこれを使用してい

教育、仕事や誕生日を提供していません呼び出す
let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"education, work, email, id, name, first_name, last_name, birthday, gender"]) 

私はFacebookから承認された次の権限を持っている:

  • user_birthday
  • user_education_history user_work_history

私は上記のコード例では、これらの値を使用しようとすると、アプリがクラッシュします存在しないフィールド:

type (User), com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=100, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={ 
    body =  { 
     error =   { 
      code = 100; 
      "fbtrace_id" = CVy14JLKraa; 
      message = "(#100) Tried accessing nonexisting field (user_birthday) on node type (User)"; 
      type = OAuthException; 
     }; 
    }; 
    code = 400; 
}} 

私は私に対して、ユーザIDとグラフ要求を使用しよう:

message = "(#100) Tried accessing nonexisting field (user_birthday) on node type (User)"; 

任意の提案:

let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "/\(fbid)", parameters: ["fields":"user_birthday"]) 
        graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in ... 

私も同じエラーが出ますか?

+0

user_birthdayというフィールドはありません。 – WizKid

+0

http://stackoverflow.com/a/40082252/6656894この回答を参照してください –

+0

http://stackoverflow.com/a/40816501/6656894またこの回答を参照してください –

答えて

0

フォローしてください。 あなたのために働くかもしれません。

#define K_Field @"fields" 
#define K_Permission @"email,location, birthday, name, link" 
#define K_ID @"id" 
#define K_Name @"name" 
#define K_DOB @"birthday" 
#define K_Email @"email" 



     FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; 
     [login logOut]; 
     login.loginBehavior = FBSDKLoginBehaviorWeb; 

     [login 
     logInWithReadPermissions: @[K_Email] 
     fromViewController:self 
     handler:^(FBSDKLoginManagerLoginResult *user, NSError *error) { 
      if (error || user.isCancelled) { 
       NSLog(@"Process error"); 
      } else { 
       if ([FBSDKAccessToken currentAccessToken]) { 
        [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{K_Field: K_Permission}] 
         startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 
          if (!error) { 
           NSLog(@"fetched user:%@", result); 
           //Done login 
          } 
         }]; 
       } 
      } 
     }]; 

あなたはそれがユーザーのIDを収集し、グラフAPIアクセスから公共の詳細を取得することにより、FacebookのグラフAPIを使用して可能であるfacebook official docs

0

と同じ右のキーワードを使用していることを確認してください:

$fb->get('/me?fields=name,first_name,last_name,email,birthday'); 
関連する問題