Forum Moderators: coopster
i have the following code that fetches a remote webpage:
$open = fopen("http://www.example.com/page.htm", "r");
$read = fread($open, 9024);
fclose($open);
echo $read;
while fetching the remote webpage i want my code to tell the remote webpage that my user agent is NSPlayer/9.0.0.2980 WMFSDK/9.0 otherwise the webpage does not display the relevant information i need.
can anyone please tell me how i can do this?
thanx
$user_agent = 'NSPlayer/9.0.0.2980 WMFSDK/9.0';
$url='http://www.example.com/page.htm';
$cookies = 'cookies';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
$html = curl_exec($ch);
$error = curl_error($ch);
echo (($error!= "")? ('Error: ' . $error) : $html);
curl_close($ch);
More info about cURL [php.net].
P.S.: Example has cookie support.