Question

I'm trying to use Facebook GraphAPI 2.0 to fetch user's id, first_name, and the url of profile picture(with special size modifiers) with single request. Here are my attempts:

  1. If simply ask for picture, we can use: "me/picture?redirect=0&height=200&type=square&width=200" ==>It's successful.

  2. If ask batch of information without special requirement of picture, we use: "me?fields=id,picture,first_name" ==> It's also successful.

  3. Now, combining the two together, I tried: "me?fields=id,first_name,picture.fields(redirect(0), type(square),width(100))" as instructed by https://developers.facebook.com/docs/graph-api/using-graph-api/v2.0#reading (the paragraph of "Making Nested Requests"). It returns error...

Thanks for any advice. you can use GraphAPI Explorer to check: https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Did%2Cname&version=v2.0

Was it helpful?

Solution

You don't need the redirect parameter if you also query for other fields:

GET /me?fields=id,first_name,picture.type(square).width(200).height(200)

should do. Note that the format (max. witdth/height) is determined by the largest edge. For my profile pic for example the width/height was 140 when requesting 200 like above.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top