title: php, curl_exec response return additional info aside from json
body: <p>I'm currently using gifs.com API with php using CUrl but the response I get isn't pure JSON</p>
  
  <p>The code below is the response i get from <code>curl_exec()</code></p>
  
  <pre><code>HTTP/1.1 200 OK Server: nginx Date: Thu, 02 Nov 2017 16:34:48 GMT Content-
  Type: application/json Content-Length: 472 Access-Control-Allow-Credentials: 
  false Access-Control-Allow-Headers: Origin, Accept,Content-Type,Gifs-API-Key 
  Access-Control-Allow-Methods: GET,POST,OPTIONS Access-Control-Allow-Origin: 
  * Access-Control-Max-Age: 43200 Request-Id: 942c0be8-0613-4c43-8fc0-
  fbedf62e7008 Via: 1.1 google Alt-Svc: clear 
  { "success": 
      { "page": "https://gifs.com/gif/9QQDvZ", 
        "oembed": "https://gifs.com/oembed/9QQDvZ", 
        "embed": "&lt;iframe src='https://gifs.com/embed/9QQDvZ' frameborder='0' scrolling='no' width='377' height='377' style='-webkit-backface-visibility: hidden;-webkit-transform: scale(1);' &gt;&lt;/iframe&gt;", 
          "files": { 
            "gif": "https://j.gifs.com/9QQDvZ.gif", 
            "jpg": "https://j.gifs.com/9QQDvZ.jpg", 
            "mp4": "https://j.gifs.com/9QQDvZ.mp4" } 
        } 
  } 
  </code></pre>
  
  <p><code>json_decode()</code> will just return null if i use it on the response, and i tried <code>substr()</code> to remove the extra characters but that wouldn't be consistent since the amount of characters will keep changing</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>below is the curl configuration</p>
  
  <pre><code>  $url = 'https://api.gifs.com/media/import';
    $headers = array("Gifs-API-Key: willnotbedisplayed", "Content-Type: application/json"); // cURL headers for file uploading
    $postfields = "{\n \"source\": \"willnotbedisplayed\",\n \"title\": \"guineapig\",\n \"tags\": [\"crazy\", \"hand drawn\", \"2015\", \"art\"],\n \"attribution\": {\n   \"site\": \"vine\",\n   \"user\": \"someone\"\n }\n}";
    $ch = curl_init();
    $options = array(
        CURLOPT_URL =&gt; $url,
        CURLOPT_HEADER =&gt; true,
        CURLOPT_POST =&gt; 1,
        CURLOPT_HTTPHEADER =&gt; $headers,
        CURLOPT_POSTFIELDS =&gt; $postfields,
        CURLOPT_RETURNTRANSFER =&gt; true
    ); // cURL options
    curl_setopt_array($ch, $options);
    $server_output = curl_exec($ch);
  </code></pre>