title: PHP Curl and API
body: <p>maybe this question was answered before but, I tested everything what i found on a web, and couldn't make it work...
  I have to form this kind of request with PHP. </p>
  
  <ul>
  <li>curl ­X POST "<a href="https://page.com/login/CODE" rel="nofollow noreferrer">https://page.com/login/CODE</a>" \ </li>
  <li>­H "Accept: application/json, text/*;q=0.2" \</li>
  <li>H "Accept­Charset: utf­8" \</li>
  <li>­H "Accept­Encoding: gzip, deflate" \</li>
  <li>d '{"appCode": "CODE"}' \</li>
  <li>--cacert cacert.pem \</li>
  <li>--compressed</li>
  </ul>
  
  <p>Here is my php code:</p>
  
  <pre><code>$data = array('appCode'=&gt;'CODE');
  $data_json = json_encode($data);
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_CAINFO, "cacert.pem");
  curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($curl, CURLOPT_URL, URL_REQUEST);
  curl_setopt($curl, CURLOPT_HEADER, FALSE);
  curl_setopt($curl,CURLOPT_ENCODING , "");
      //curl_setopt($ch, CURLOPT_POST, 1);
      //curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($curl, CURLOPT_POSTFIELDS, $data_json);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  </code></pre>
  
  <p>If I get a correct answer from API it should be a JSON array, alse massage Login Error.</p>
  
  <p>Got no Idea what is this text/*;q=0.2", any suggestions what I am doing wrong?</p>
  
  <p><strong>If someone will need here the code that helped me:</strong></p>
  
  <pre><code>$data = array('appCode'=&gt;'CODE');
  $data_json = json_encode($data);
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($curl, CURLOPT_CAINFO, "cacert.pem");
  curl_setopt_array($curl, array(
      CURLOPT_URL =&gt; "https://login.com/CODE",
      CURLOPT_RETURNTRANSFER =&gt; true,
      CURLOPT_ENCODING =&gt; "",
      CURLOPT_MAXREDIRS =&gt; 10,
      CURLOPT_TIMEOUT =&gt; 30,
      CURLOPT_HTTP_VERSION =&gt; CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST =&gt; "POST",
     CURLOPT_POSTFIELDS =&gt; $data_json,
     CURLOPT_HTTPHEADER =&gt; array('cache-control: no-cache'),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
      echo "cURL Error #:" . $err;
  } else {
     echo $response;
  }
  </code></pre>
  
  <p><strong>Eventually i find out what was wrong.</strong></p>
  
  <p>I got all the manual at pdf file.
  I was copying header information from pdf and pasting it into
  <a href="https://www.sublimetext.com/" rel="nofollow noreferrer" title="Sublime">Sublime</a> 
  When I copy and paste header information like this 
  <strong>Content-Type: application/json</strong></p>
  
  <p>On sublime it was shown normally with dash (-) but when i opened with other software like notepad++ it was showing without dash.
  <strong>ContentType: application/json</strong></p>
  
  <p>That was the problem why my code didn't work :)</p>