Graph API for user returns false even with a valid user access token
About 2% of the time, a user authorizes my Facebook App and with a valid access token, I call Facebook's Graph API only to get back the value "false" instead of a JSON representation of user information. For example:
https://graph.facebook.com/{user_id}?access_token={user_access_token}
--> returns "false"
I can't seem to reproduce the problem myself. My problem may be related to this answer: http://facebook.stackoverflow.com/questions/5085957/facebook-graph-api-returns-false-for-page-accounts/6595465#6595465
but I can't access my App when I'm logged in as a 开发者_运维技巧Page as the answer above suggests, so I have no way to verify whether my problem is the same or not.
Any suggestions?
UPDATE (2011-09-29)
It turns out that this problem happens whenever a user does not have a completed profile. You can reproduce this problem by first logging out of Facebook then creating a Facebook Page here:
http://www.facebook.com/pages/create.php
During the Page creation process, Facebook will ask you to log in with an existing account or create a new one. If you create a new one, Facebook will create a user account for you, but the user account will not have a completed Profile. So instead of Facebook's API providing the information they do have about the user (i.e. the info that it collected during the sign-up process), it returns false. Once the user "Creates a Profile", then Facebook's API will return the proper user graph.
The 'false' return almost always means you're trying to access a piece of content that the current user (or page, app, etc depending on your access_token
) has no permission to view.
If you're definitely calling /{user_id}
, with a user access token, it's most likely that either the user has Platform disabled, or the user has the session user blocked.
Facebook returns JSON representation of data for a {user_id} (as per your usage) when that user id is either a Profile ID, App Id or Page ID
false is returned when it is neither of the three.. There is something wrong with the {user_id} that you are using. You should log the ids for which you get this error and try making a graph call to then like http://graph.facebook.com/{user_id}.. if this again returns false you will be sure of the fact that it is a wrong id ,,
精彩评论