Github API v3 POST with PHP

Inhitigwent

New Member
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;\[code\]Array( [message] => Body should be a JSON Hash )\[/code\]I have gone over the relevant page on the API Docs: http://developer.github.com/v3/users/And this page: http://developer.github.com/v3/#http-verbs which covers POST/PATCHHere is the code that I'm using\[code\]$data = http://stackoverflow.com/questions/10542835/array("bio" => "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\]I have also tried \[code\]CURLOPT_CUSTOMREQUEST\[/code\] as \[code\]'POST'\[/code\] and \[code\]'PATCH'\[/code\] but got the same error response for both. Can anyone point me in the right direction for posting data to the API?
 
Back
Top