0

I am working with the batch request of the Facebook. I have tried the api call as shown below. Is there anything wrong here?

[{"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>

here xxxxxx is the facebook userid and access_token=xxxxxx|xxxxxxxxxxx is facebook app access token.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
insomiac
  • 5,648
  • 8
  • 45
  • 73
  • Here's how to do it in the PHP SDK: http://stackoverflow.com/questions/4107587/batch-calls-with-facebook-graph-api-php/7296533#7296533 – buzzedword Apr 27 '12 at 18:57

2 Answers2

0

I see a few problems:

  1. Set the access token as a separate parameter, not included as part of the relative_url attribute in the JSON payload.
  2. Don't include the message as part of the relative_url. Create a body attribute instead and pass message=hello as the value.

e.g.

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'
TMC
  • 8,088
  • 12
  • 53
  • 72
0

The urls passed in the batch need to be urlencoded.

Kilian Schefer
  • 579
  • 5
  • 18