2

Facebook SDK v.3.18.2 を使用しています

ユーザーの名、姓、電子メール、生年月日のみが必要です。生年月日以外のすべてを取得しています。

私は確かに許可を間違えていますか?わからない。

私の問題を見つけるのに役立つコードを次に示します。

    [FBSession openActiveSessionWithReadPermissions:@[@"public_profile"] allowLoginUI:YES completionHandler:
     ^(FBSession *session, FBSessionState state, NSError *error) {
         // Call the sessionStateChanged:state:error method to handle session state changes
         [self sessionStateChanged:session state:state error:error];
     }];

// This method will handle ALL the session state changes in the app
- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError     *)error
{
    // If the session was opened successfully
    if (!error && state == FBSessionStateOpen){
        NSLog(@"Session opened");
        if (FBSession.activeSession.isOpen) {

//            This is not working though I'm putting it as comment
//            [[FBRequest requestForMe] startWithCompletionHandler:
//             ^(FBRequestConnection *connection,
//               NSDictionary<FBGraphUser> *user,
//               NSError *error) {
//                 if (!error) {
//                     NSLog(@"User Info : %@",user);
//                 }
//             }];
        
        [[FBRequest requestForGraphPath:@"me"] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
            NSLog(@"%@",result);
        }];
    }
    return;
}

出力ログは次のとおりです。

{
    email = "email@domain";
    "first_name" = Hemang;
    gender = male;
    id = someId;
    "last_name" = Shah;
    link = "https://www.facebook.com/app_scoped_user_id/someId/";
    locale = "en_US";
    name = "Hemang Shah";
    timezone = "5.5";
    "updated_time" = "some date and time";
    verified = 1;
}

でも生年月日が抜けていて、プロフィールにも設定しました。

アップデート:

次の権限で試してみましたが、機能しませんでした!

「user_birthdate」または「birthday」

4

2 に答える 2

2
 [FBSession openActiveSessionWithReadPermissions:@[@"email",@"user_birthday",@"public_profile"]
                                   allowLoginUI:YES
                              completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {

                                  switch (state) {
                                      case FBSessionStateOpen:
                                          [[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
                                              if (error) {

                                                  NSLog(@"error:%@",error);


                                              }
                                              else
                                              {
                                                  // retrive user's details at here as shown below
                                                  NSLog(@"FB user first name:%@",user.first_name);
                                                  NSLog(@"FB user last name:%@",user.last_name);
                                                  NSLog(@"FB user birthday:%@",user.birthday);
                                                  NSLog(@"FB user location:%@",user.location);                                                      NSLog(@"FB user gender:%@",[user objectForKey:@"gender"]);
                                                  NSLog(@"email id:%@",[user objectForKey:@"email"]);
                                                  NSLog(@"location:%@", [NSString stringWithFormat:@"Location: %@\n\n",
                                                                         user.location[@"name"]]);

                                              }
                                          }];
                                          break;

                                      case FBSessionStateClosed:
                                      case FBSessionStateClosedLoginFailed:
                                          [FBSession.activeSession closeAndClearTokenInformation];
                                          break;

                                      default:
                                          break;
                                  }

                              } ];

参照が必要 :このリンクを使用

コンソール出力は次のとおりです。ここに画像の説明を入力

サンプルプロジェクトを添付し- (IBAction)loginwithCustomButaction:(id)sender 、プロジェクトのリンクを確認します

于 2014-10-01T10:51:12.297 に答える
0

"user_birthday"とともに求める必要がありますpublic_profile

詳細については、こちらの Facebook ドキュメントをご覧ください

公開プロフィール リクエスト カバー

  • ID
  • 名前
  • ファーストネーム
  • 苗字
  • リンク
  • 性別
  • ロケール
  • 年齢層

デフォルトのパブリック プロファイル以外の追加の権限を要求する場合は、アプリの審査を受ける必要があることに注意してください。

于 2014-10-01T10:29:06.663 に答える