title: curl request with headers in PHP
body: <p>I want to make a cURL request to a URL along with the following headers :</p>
  
  <p><strong>'Content-Type: application/json',
  'Authorization': 'Basic XXXXXXXXXX'</strong></p>
  
  <p>I have the following code :</p>
  
  <pre><code>&lt;?php
  
  $post_url = "https://api.interlinkexpress.com/user/?action=login";
  
  $curl = curl_init($post_url);
  
  $headers = array(
          'Content-Type: application/json',
          'Authorization': 'Basic XXXXXXXXX'
          );
  //curl_setopt($curl, CURLOPT_USERPWD, "username":"Password");
  curl_setopt($curl, CURLOPT_URL, $post_url);
  curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($curl, CURLOPT_POST, true);
  //curl_setopt($curl, CURLOPT_POSTFIELDS,json_encode($post_data) );
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); 
  $post_response = curl_exec($curl); 
  
  ?&gt;
  </code></pre>
  
  <p>it is showing the result as :</p>
  
  <blockquote>
    <p>Client sent a Bad Request</p>
  </blockquote>
  
  <p>which is the 'Authorization...' line under the $header array</p>
  
  <p>Any suggestions/help is appreciated.</p>