Howto add Modifiers to Graph API V2.0

烂漫一生 提交于 2019-12-25 18:13:32

问题


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


回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!