问题
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:
If simply ask for picture, we can use: "me/picture?redirect=0&height=200&type=square&width=200" ==>It's successful.
If ask batch of information without special requirement of picture, we use: "me?fields=id,picture,first_name" ==> It's also successful.
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
回答1:
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.
来源:https://stackoverflow.com/questions/23652432/howto-add-modifiers-to-graph-api-v2-0