PHPcurl simulates login to obtain cookies. Cainiao learns to use PHP & nbsp; curl to simulate login. when we use the following code to log on to www.xiaomi.com, the login will fail. The cookie is obtained. Please help me solve the problem. PHP curl simulates login to obtain cookie for help
Cainiao learns to use PHP curl to simulate login. when the following code is used to successfully log on to www.xiaomi.com, the login will fail. The cookie is obtained. Please help me solve the problem. Think about what you can't do at night without income!
$ Cookie_file = tempnam ('./temp', 'cooker ');
$ Login_url = 'https: // account.xiaomi.com/pass/serviceloginauth ';
$ Post = 'User & pwd = & sid = eshop & callback = http % 3A % 2F % 2Forder.xiaomi.com % 2 Flogin % 2 Fcallback % 3 Ffollowup % 3 Dhttp % 253A % 252F % 252Fwww.xiaomi.com % 252F % 26 sign % percent % 2C % 2C & _ sign = f % 2FKB8SAfmaLZ0s28kcLtBSmZlEM % 3D & _ json = true' // remove the post account and password from unnecessary troubles
$ Ch = $ curl = curl_init ($ login_url );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 0 );
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookie_file );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ post );
Curl_exec ($ ch );
Curl_close ($ ch );
$ Url = "http://www.xiaomi.com/index.php ";
$ Ch = curl_init ($ url );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 0 );
Curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ cookie_file );
$ Contents = curl_exec ($ ch );
Curl_close ($ ch );
?>
Share:
------ Solution --------------------
Account name error
Enter account name
Enter password