curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"firstname":"Mike","lastname":"Doel","customer_id":"12345","email":"[email protected]"}' -u API-key: APIURL(http://)
obigen Aussage ist im Befehl ausgeführt wird, aber ich bin nicht in der Lage, das gleiche von PHP-Code achive unten ist mein CodePHP cURL, POST JSON Fehler immer in php curl
$url="https://apiurl";
$data=array("firstname"=>"Mike","lastname"=>"Doel","customer_id"=>"12345","email"=>"[email protected]");
$data_json=json_encode($data);
//Curl code
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',"Accept: application/json","api-key"));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
haben Sie eine Benutzer-ID oder ein Passwort für API-Schlüssel übergeben? –
Bitte beachten Sie http://StackOverflow.com/Questions/3062324/what-is-curl-in-PHP –