Skip to content

Instantly share code, notes, and snippets.

@dmalan
Created August 26, 2014 12:44
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 dmalan/9c15ef33ec3725af1ed9 to your computer and use it in GitHub Desktop.
Save dmalan/9c15ef33ec3725af1ed9 to your computer and use it in GitHub Desktop.
<?php
// headers for proxy servers
$headers = [
"Accept" => "*/*",
"Connection" => "Keep-Alive",
"User-Agent" => sprintf("curl/%s", curl_version()["version"])
];
// open connection to Yahoo
$context = stream_context_create([
"http" => [
"header" => implode(array_map(function($value, $key) { return sprintf("%s: %s\r\n", $key, $value); }, $headers, array_keys($headers))),
"method" => "GET"
]
]);
$handle = fopen("http://www.xhaus.com/headers", "r", false, $context);
if ($handle === false)
{
// trigger (big, orange) error
trigger_error("Could not connect to Yahoo!", E_USER_ERROR);
exit;
}
$contents = fread($handle, 1048576);
print_r($contents);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment