title: What is the format of HTTP POST data used in Graph API?
body: <p>I am using Graph API <a href="https://developers.facebook.com/docs/reference/api/#publishing" rel="nofollow">https://developers.facebook.com/docs/reference/api/#publishing</a> with PHP SDK and I would like to send some data via HTTP POST method, as it's mentioned in documentation (e.g. add comment).</p>
  
  <p>At <a href="https://developers.facebook.com/docs/reference/api/batch/" rel="nofollow">https://developers.facebook.com/docs/reference/api/batch/</a> they say I should encode the body of HTTP POST request as <em>...should be formatted as a raw HTTP POST body string, similar to a URL query string</em>. I can't get the combination of PHP functions to get this to work. In the example they claim following should work:</p>
  
  <pre><code>"body": "message=Test status update"
  </code></pre>
  
  <p>Well, that works. But what if I need to add other params? And how should be this string encoded? E.g. I have this:</p>
  
  <pre><code>$data = array('name' =&gt; 'Gargamel', 'occupation' =&gt; 'Freelancing Smurf Hunter');
  </code></pre>
  
  <p>How should I process it to get required format? Following does NOT work:</p>
  
  <pre><code>$batch = array();
  $query = array(
      'method' =&gt; 'POST',
      'relative_url' =&gt; '/forrest/full/of/smurfs',
      'body' =&gt; urldecode(http_build_query($data)),
  );
  $batch[] = $query;
  $responses = $this-&gt;api('/?batch=' . json_encode($batch, JSON_HEX_AMP), 'POST');
  </code></pre>
  
  <p>I explored half of the Internet, but I can't find any more specific information about the format than the one mentioned above (raw HTTP POST similar to a URL query string).</p>
  
  <p>Thanks for any suggestions!</p>