EVA
EVA

Reputation: 375

Received error response when Get a Facebook user's basic info

I'm doing it on ios. When I get a user's info(gendar,locale,etc), such as Bill Gates(216311481960), it will return error. Maybe because these info are not public. If I just get name,link, picture, that will be OK. But how can I handle this kind of error. How can I know which info can be retrieved?

Thanks.

Upvotes: 0

Views: 215

Answers (1)

DMCS
DMCS

Reputation: 31870

Without a user access token, pubic info can be grabbed this way: http://graph.facebook.com/216311481960

{
   "id": "216311481960",
   "name": "Bill Gates",
   "picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/276582_216311481960_498814368_s.jpg",
   "link": "http://www.facebook.com/BillGates",
   "likes": 1216122,
   "category": "Public figure",
   "is_published": true,
   "website": "www.thegatesnotes.com www.gatesfoundation.org",
   "username": "BillGates",
   "talking_about_count": 25035
}

As you can see this doesn't appear to be user information, but rather page information. For user information, you need to use a Facebook user id. Zuck's is 4...so do: http://graph.facebook.com/4

{
   "id": "4",
   "name": "Mark Zuckerberg",
   "first_name": "Mark",
   "last_name": "Zuckerberg",
   "link": "http://www.facebook.com/zuck",
   "username": "zuck",
   "gender": "male",
   "locale": "en_US"
}

Notice how it has both first_name and last_name, while the "Bill Gates" one you have as an example is clearly not a "user" but a page.

With a valid user access token, all shared information can be grabbed this way:

http://graph.facebook.com/me?access_token=ValidUserAccessToken

Upvotes: 1

Related Questions