4

何らかの理由で、Facebook は、ユーザーの認証に成功した後に返されるユーザー JSON でユーザーの電子メールを返さなくなりました。

FacebookSDK for iOS を v3.6 から v3.8 にアップグレードしましたが、運が悪かったです。数週間前まではすべて正常に機能していましたが、現在は機能していません。メールだけで、他のすべてのプロパティ、つまりDOBは問題なく戻ってきます。Facebook はアクセス許可システムを変更し続けていますが、最近の変更が原因である可能性があることを私は知りません。任意のポインタをいただければ幸いです。

ところで、有効な電子メールが関連付けられている自分の FB アカウントで認証しようとしていますが、最近プライバシー設定も変更していません。

また、Facebook のプライバシー設定からアプリを削除して再認証しようとしましたが、それでもうまくいきません。コードは次のとおりです。

[FBSession openActiveSessionWithReadPermissions:@[@"user_about_me", @"user_location", @"user_birthday", @"email"] allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
    switch (status) {
        case FBSessionStateOpen: {
            [[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
                NSLog(@"User Data: %@", user);      //no email in the json
                NSString *email = user[@"email"];   //obviously returns nil
                //rest of the code
            }];
        }
            break;
        case FBSessionStateClosed:
        case FBSessionStateClosedLoginFailed:
            [FBSession.activeSession closeAndClearTokenInformation];
            break;
        default:
            break;
    }
}];

正しく構成したことを明確に示す Facebook アプリのアクセス許可ページのスクリーンショット:

ここに画像の説明を入力

API コールバックで返されるユーザー JSON を次に示します (個人情報は削除しました)。

{
    bio = "My Bio";
    birthday = "01/01/1900";
    "first_name" = FN;
    gender = male;
    id = 00000000;
    "last_name" = LN;
    link = "https://www.facebook.com/FBName";
    locale = "en";
    location =     {
        id = 11111111111111111;
        name = "City Name";
    };
    name = "FN LN";
    quotes = "";
    timezone = "0";
    "updated_time" = "2000-00-07T00:00:21+0000";
    username = USERNAME;
    verified = 1;
}
4

1 に答える 1

5

It turned out that Facebook does not return user email when you make a graph call if primary email associated with that Facebook account has been deactivated, disabled, or deleted.

It can happen if you do not access your email address for a long time. Facebook probably figures it out when their emails to your primary address start bouncing back.

Steps to make it work again:

  1. Please make sure you are able to login to your email account and Facebook emails are not getting bounced.

  2. Login to Facebook and change your primary email address to some other email.

  3. Facebook will send a verification email to your new email address, open this email and click verify link.

  4. Log back in to Facebook and change your primary email again to the previous email address.

  5. Facebook will send a verification email to this email address, please open it and click on it to verify your email.

  6. Wait for a couple of hours and try again viola, your email will start coming down in the json.

于 2013-12-24T19:59:58.183 に答える