facebook多个用户批量请求 [英] facebook batch request for multiple users

查看:131
本文介绍了facebook多个用户批量请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户数据库。我想使用批量请求获取他们的数据(兴趣和朋友生日)。现在我可以为1个用户发出1个批量请求。但考虑到不。在我的应用程序中的用户是非常重要的,它将达到极限。



我想知道是否有任何方式在批量请求中获取多个用户的数据



我尝试了以下操作,但它没有工作



access_token:USER_A_ACCESS_TOKEN,
批处理= [
{method:GET,access_token:USER_A_ACCESS_TOKEN,relative_url:me / friends},
{method:GET,access_token :USER_B_ACCESS_TOKEN,relative_url:我/朋友}
]



对于userB访问令牌,我还得到用户A访问令牌的结果


解决方案

根据批次请求页面上的文档

 批量API是灵活的,允许个别请求指定自己的
访问令牌作为查询字符串或表单后置参数。在这种情况下,顶级
级访问令牌被认为是备用令牌,如果单个
请求没有明确指定访问令牌,则使用它。

重写原来的尝试应该是这样的



< pcurl -Faccess_token = USER_A_ACCESS_TOKEN-F'batch = [{method:GET,ative_url:me / friends?access_token = USER_A_ACCESS_TOKEN},{method:GET relative_url:我/朋友?access_token = USER_B_ACCESS_TOKEN}]'



如果任何其他access_tokens有错误,原来的USER_A_ACCESS_TOKEN将被用作回退


I have a user database from facebook. I want to get their data (interests and friends birthdays) using batch request. Now I can make 1 batch request for 1 user. But considering the no. of users in my app is huge definately it will reach a limit.

I want to know if there is any way to get multiple users data in a batch request

I tried the following but it didn't work

"access_token": "USER_A_ACCESS_TOKEN", batch=[ {"method": "GET", "access_token": "USER_A_ACCESS_TOKEN", "relative_url": "me/friends"}, {"method": "GET", "access_token": "USER_B_ACCESS_TOKEN", "relative_url": "me/friends"} ]

For userB access token also i get results for user A access token

解决方案

According to the documentation on the batch requests page

The Batch API is flexible and allows individual requests to specify their own
access tokens as a query string or form post parameter. In that case the top
level access token is considered a fallback token and is used if an individual
request has not explicitly specified an access token.

Rewriting your original attempt should be like this

curl -F "access_token=USER_A_ACCESS_TOKEN" -F 'batch=[{"method": "GET", "relative_url": "me/friends?access_token=USER_A_ACCESS_TOKEN"}, {"method": "GET", "relative_url": "me/friends?access_token=USER_B_ACCESS_TOKEN"}]'

The original USER_A_ACCESS_TOKEN will be used as a fallback if there is an error with any of the other access_tokens

这篇关于facebook多个用户批量请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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