title: Github API v3 POST with PHP
body: <p>I'm attempting to use the Github v3 API and posting JSON to update a profile (or some other call) and get the following response from Github;</p>
  
  <pre><code>Array
  (
      [message] =&gt; Body should be a JSON Hash 
  )
  </code></pre>
  
  <p>I have gone over the relevant page on the API Docs: <a href="http://developer.github.com/v3/users/" rel="nofollow">http://developer.github.com/v3/users/</a></p>
  
  <p>And this page: <a href="http://developer.github.com/v3/#http-verbs" rel="nofollow">http://developer.github.com/v3/#http-verbs</a> which covers POST/PATCH</p>
  
  <p>Here is the code that I'm using</p>
  
  <pre><code>$data = array("bio" =&gt; "This is my bio" );
  $data_string = json_encode($data); 
  
  function curl($url) {
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL,$url);
      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 
      curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);  
  
      curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,1);
      curl_setopt($ch, CURLOPT_USERPWD, "USERNAME:PASSWORD");
      curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);   
      $content = curl_exec($ch);
      curl_close($ch);
      return $content;
  }
  
  $result = json_decode(curl('https://api.github.com/user'),true);
  </code></pre>
  
  <p>I have also tried <code>CURLOPT_CUSTOMREQUEST</code> as <code>'POST'</code> and <code>'PATCH'</code> but got the same error response for both. </p>
  
  <p>Can anyone point me in the right direction for posting data to the API?</p>