Skip to content

Instantly share code, notes, and snippets.

@jamesmills
Created June 10, 2013 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmills/5748138 to your computer and use it in GitHub Desktop.
Save jamesmills/5748138 to your computer and use it in GitHub Desktop.
Get curl header
<?php
$ch = curl_init('http://cts-web-api.cloudapp.net/api/hotels?destination=mgm');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Range: items=1-5'));
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
echo '<pre>';
print_r($header_size);
print_r($header);
print_r($body);
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment