简体   繁体   中英

Facebook SDK v4 + Parse 1.7.5 issue

I've updated my SDKs from Facebook and Parse to the newest ones which includes some change in the PFFacebookUtils structure.

I would like to create a PFUser with some content from FB. It have been working for a long time before the update, but now when I log in, I only receive the user's name and FBID as result from the Facebook request.

This is how "I" log in:

NSArray *permissionsArray = @[@"public_profile", @"email", @"user_education_history", @"user_work_history", @"user_birthday", @"user_friends", @"user_photos"];

[PFFacebookUtils logInInBackgroundWithReadPermissions:permissionsArray block:^(PFUser *user, NSError *error) { ... }];

This is how I try to get the results:

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil];
        [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    NSLog(@"Result %@", result);
    ...
}];

The log only shows this:

    2015-08-03 01:41:15.039 XXXXXX[10807:2640469] Result {
        id = 1015XXXXXXXXXXXX;
        name = "Simon XXXX";
    }

The Facebook App ID is set in the pList.

The latest Facebook SDK uses the Graph API v2.4, so the special me request needs the specific fields as query parameters to the graph path.

So, if you need to access the first, last name and email, the graph path in your code would look something like this:

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me?fields=first_name,last_name,email" parameters:nil];
        [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    NSLog(@"Result %@", result);
    ...
}];

I also suggest that you check out and play with the Graph API Explorer (note the API version dropdown in the top right corner).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM