Pregunta

I've been using v1.0 of the Facebook SDK for iOS without any problem. I am trying to simply fetch the first and last name of another facebook user, than the one currently owning the session, but with the new version, this call fails terribly.

For login I use the FBLoginView, I'm setting it up like this:

facebookLoginView.loginBehavior = FBSessionLoginBehaviorUseSystemAccountIfPresent;
facebookLoginView.readPermissions = @[@"public_profile", @"email", @"user_likes"];
facebookLoginView.delegate = self;

Then, when I get the permissions, I have an active session (I checked the access token, it is valid for the application I'm using - I checked it with the graph api explorer), I'm doing this:

[FBRequestConnection startWithGraphPath:@"https://graph.facebook.com/100005627796553" parameters:nil HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
    NSLog(@"%@", result);
}];

The console log, that follows simply says, instead of a json string containing the user's profile data (the public ones) this:

{id = "https://graph.facebook.com/100005627796553";}

Any idea is greatly appreciated.

¿Fue útil?

Solución

From what I can understand, you are running into the restrictions that the 2.0 API places around interacting with users who have not run your app and given it any permissions.

This is a radical departure from 1.0 where the user of your app could allow your app access to data about their friends. In the new API, the friend must have used your app and granted permissions for your app to see their data.

One of the ways that Facebook is implementing this is that user ID numbers are app specific in 2.0. i.e. If you happen to know someone's Facebook user ID, perhaps from a 1.0 based app, it is not usable by your app. There is no way to ask for a complete list of a user's friends anymore, although there are some API calls to do things like tag photos with friends or invite friends that have not used your app - but this still doesn't give you access to their profiles. The IDs these APIs give you can't be used that way.

The changes are described here: Upgrading to 2.0 User IDs

If these seem pretty restrictive to you, you're not alone. Thank the spammers out there.

Otros consejos

It turns out, that the problem was rooted in the URL I used for the call, the correct version doesn't have to contain the "https://graph.facebook.com/" part, just the rest of the URL, like this:

[FBRequestConnection startWithGraphPath:@"https://graph.facebook.com/100005627796553" parameters:nil HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
    NSLog(@"%@", result);
}];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top