In the following code, I have successfully obtained cookies and saved them in the txt file, but cannot jump to the logon page. Ask?]. Phpcurl
In the following code, I have successfully obtained cookies and saved them in the txt file, but cannot jump to the logon page. Ask?
$ 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 );
?>