How to set header in PHP?
I'm trying to get the data from a website but when i'm making
file_get_contetnts it gets me the data transleted to my server region, how
can i do it to get the default US values?
i'm doing like this:
$url = 'URL';
print_r(get_headers($url));
print_r(file_get_contents($url));
UPDATE: i also tried this:
$options = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n" . // check
function.stream-context-create on php.net
"User-Agent: Mozilla/5.0 (iPad; U;
CPU OS 3_2 like Mac OS X; en-us)
AppleWebKit/531.21.10 (KHTML, like
Gecko) Version/4.0.4 Mobile/7B334b
Safari/531.21.102011-10-16
20:23:10\r\n" // i.e. An iPad
)
);
$context =
stream_context_create($options);
$imdb = file_get_contents("URL",false,$context);
Thanks!
No comments:
Post a Comment