php-PHP curl模拟登录网站但被困在登录页面
在以下的代码中我已经成功获取了cookies并保存在txt文档里,但是无法跳转到登录页面。请教?
$ch = curl_init();
$data='email= &password= &autologin=0';
$cookie_file=fopen($_SERVER['DOCUMENT_ROOT']."\cookies.txt","w");
curl_setopt($ch, CURLOPT_URL, "http://www.imooc.com/user/newlogin/from_url/1003");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_COOKIEJAR,$_SERVER['DOCUMENT_ROOT']."\cookies.txt");
curl_setopt($ch,CURLOPT_COOKIEFILE,$_SERVER['DOCUMENT_ROOT']."\cookies.txt");
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_exec($ch);
curl_setopt($ch,CURLOPT_URL,"http://www.imooc.com/space/index");
curl_setopt($ch,CURLOPT_POST,0);
$output=curl_exec($ch);
echo $output;
curl_close($ch);
?>