2011-12-11 86 views
0

我正在處理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://stackoverflow.com/questions/4107587/batch-calls-with-facebook-graph-api-php/7296533#7296533 – buzzedword

回答

0

我看到了幾個問題:

  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' 
0

批次中傳遞的網址需要進行urlencoded。