如何将修饰符添加到Graph API V2.0 [英] Howto add Modifiers to Graph API V2.0

查看:76
本文介绍了如何将修饰符添加到Graph API V2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Facebook GraphAPI 2.0来通过单个请求获取用户的ID,first_name和个人资料图片的网址(带有特殊的大小修饰符).这是我的尝试:

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. 如果只是索要图片,我们可以使用:"me/picture?redirect = 0& height = 200& type = square& width = 200" ==>成功.

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

如果不要求有图片的特殊要求而查询大量信息,则使用:"me?fields = id,picture,first_name" ==>也成功.

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

现在,将两者结合在一起,我尝试: https://developers.facebook.com/docs/graph -api/using-graph-api/v2.0#reading (进行嵌套请求"的段落).它返回错误...

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...

谢谢您的任何建议.您可以使用GraphAPI Explorer进行检查: https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Did%2Cname&version=v2.0

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

推荐答案

如果您还查询其他字段,则不需要redirect参数:

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)

应该做.请注意,格式(最大宽度/高度)由最大边缘决定.例如,对于我的个人资料照片,当请求200像上面一样时,宽度/高度为140.

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.

这篇关于如何将修饰符添加到Graph API V2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆