Created
August 26, 2014 12:44
-
-
Save dmalan/9c15ef33ec3725af1ed9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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