批量请求查询

问题描述:

我正在处理Facebook的批量请求。我已经尝试了如下所示的api调用。这里有什么不对吗?批量请求查询

[{"method":"POST","relative_url": "xxxxxxxxx/apprequests?message=hello&access_token=xxxxxxxx|xxxxxxxxxxxxxxx"},{"method":"GET","relative_url": "xxxxxxxx/mutualfriends/xxxxxxxxx"}] 

<HTML><HEAD><TITLE>400 Bad Request</TITLE> 
</HEAD><BODY> 
<H1>Method Not Implemented</H1> 
Invalid method in request<P> 
</BODY></HTML> 

这里xxxxxx是facebook用户名和access_token = xxxxxx | xxxxxxxxxxx是Facebook应用访问令牌。

+0

以下是如何在PHP SDK中执行此操作的方法:http://*.com/questions/4107587/batch-calls-with-facebook-graph-api-php/7296533#7296533 – buzzedword

我看到了几个问题:

  1. 设置访问令牌作为单独的参数,不作为的JSON有效载荷的relative_url属性的一部分。
  2. 不包括message作为relative_url的一部分。改为创建一个body属性并将其作为值传递给message=hello

例如

curl -F 'access_token=XYZ' \ 
    -F 'batch=[{"method":"POST","relative_url":"xxxxxxxxx/apprequests", "body","message=hello"},{"method":"GET","relative_url": "xxxxxxxx/mutualfriends/xxxxxxxxx"}]' 'https://graph.facebook.com' 

批次中传递的网址需要进行urlencoded。