title: PHP cURL, POST JSON getting error in php curl
body: <pre><code>curl  -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"firstname":"Mike","lastname":"Doel","customer_id":"12345","email":"test_api_user@gmail.com.com"}' -u API-key:  APIURL(http://)
  </code></pre>
  
  <p>above statement is running well in command but i am unable to achive the same by php code below is my code</p>
  
  <pre><code>$url="https://apiurl"; 
  
  $data=array("firstname"=&gt;"Mike","lastname"=&gt;"Doel","customer_id"=&gt;"12345","email"=&gt;"test_api_user@gmail.com");
  
  $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);
  </code></pre>