php curl: how can i emulate a get request exactly like a web browser?

Posted by ufk on Stack Overflow See other posts from Stack Overflow or by ufk
Published on 2010-03-14T00:41:37Z Indexed on 2010/03/14 0:45 UTC
Read the original article Hit count: 253

Filed under:
|

Hi. there are websites that when i open specific ajax request on browser i get the resulted page, but when i try to load them with curl, i receive an error from the server.

how can i properly emulate a get request to the server that will simulate a browser ?

that's what i'm doing:

$url="https://new.aol.com/productsweb/subflows/ScreenNameFlow/AjaxSNAction.do?s=username&f=firstname&l=lastname";
ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
print $result;

© Stack Overflow or respective owner

Related posts about php

Related posts about curl