r_e_v - 2013-06-26 01:55:27
I was using script with CURL to get a cookie from a site, colected some datas from a user form e post it again to the site to receive information.
The code is:
$filename="http://aaa.com";
$cookie=$_SERVER['DOCUMENT_ROOT']."cookie.txt";
fopen($cookie,'w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $filename);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$curlResults=curl_exec($ch);
curl_close($ch);
to colect results with:
$cn = $_POST['cn'];
$ct = $_POST['ct'];
$cookie=$_SERVER['DOCUMENT_ROOT']."cookie.txt";
$post_fields = "cn=".$cn."&ct=".$ct;
fopen($cookie,'r');
$ch = curl_init();
$imgs='http://aaa.com/';
curl_setopt($ch, CURLOPT_URL, $imgs);
curl_setopt($ch, CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curlResults=curl_exec($ch);
curl_close($ch);
Now the site change to a AJAX form, with new forms and javascripts all over the place.
How can I get site data with CURL, retain cookie data, and post it into AJAX form to receive information?