使用 JavaScript SDK 批量请求限制字段
是否可以使用 JavaScript SDK 限制从 Facebook 的批量请求 API 返回的字段?例如:
FB.api('/', 'POST', {
batch: [
{ method: 'GET', relative_url: 'me'},
...
]
}, function (response) {
console.log(response);
});
上面批量请求的第一个方法返回完整的用户图。但是,如果我只想获取几个字段(例如名字和姓氏)怎么办?像这样的东西会很好,但不起作用:
batch: [
{ method: 'GET', relative_url: 'me', fields: 'first_name,last_name'},
...
]
Is it possible to limit the fields that are returned from Facebook's Batch request API using the JavaScript SDK? For example:
FB.api('/', 'POST', {
batch: [
{ method: 'GET', relative_url: 'me'},
...
]
}, function (response) {
console.log(response);
});
The first method of the batch request above returns the full user graph. However, what if I only wanted to fetch a few fields (e.g. first_name and last_name). Something like this would be nice, but doesn't work:
batch: [
{ method: 'GET', relative_url: 'me', fields: 'first_name,last_name'},
...
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于某些请求,您可以使用附加到 url 末尾的
&fields=
。就像/me?fields=first_name,last_name
With some requests you can use the
&fields=
appended to the end of the url. like/me?fields=first_name,last_name
使用 FQL 查询 过滤掉您需要的某些字段...
例如:
SELECT uid, name, first_name, pic_square FROM user WHERE uid = me()
此查询将返回当前连接的用户的 user_id、全名、名字和 50x50 像素个人资料图片。 ..
Use FQL queries to filter out certian fields your require...
eg :
SELECT uid, name, first_name, pic_square FROM user WHERE uid = me()
this query will return the user_id, full name, first name and 50x50 pixel profile picture for the user that is currently connected...