PHP Tutorial This article is a brief description of the Curl simulation login, today's small part of the code sent directly to share to everyone. However, now the revision, login public number must sweep QR code authentication. This code, I still send out, for everyone reference use!
Analog Login
$cookie _file = Tempnam ('./temp ', ' Cookie ');
$login _url = ' https://mp.weixin.qq.com/cgi-bin/login ';
$data = ' f=json&imgcode=&pwd=ae4e792c8c289cc8e390c86c99ea249b&[email protected] ';
$ch = Curl_init ($login _url);
curl_setopt ($ch, curlopt_returntransfer,true);
curl_setopt ($ch, curlopt_post,1);
curl_setopt ($ch, Curlopt_cookiejar, $cookie _file);
curl_setopt ($ch, Curlopt_ssl_verifypeer, false);
curl_setopt ($ch, Curlopt_ssl_verifyhost,false);
curl_setopt ($ch, Curlopt_referer, ' https://mp.weixin.qq.com ');
curl_setopt ($ch, Curlopt_postfields, $data);
$content = curl_exec ($ch);
Curl_close ($ch);
$newurl = Json_decode ($content, 1);
$newurl = $newurl [' Redirect_url '];
Get the source code of the page after login
$go _url = ' https://mp.weixin.qq.com '. $newurl;
$ch = Curl_init ($go _url);
curl_setopt ($ch, curlopt_returntransfer,true);
curl_setopt ($ch, Curlopt_cookiefile, $cookie _file);
curl_setopt ($ch, curlopt_connecttimeout,0);
curl_setopt ($ch, Curlopt_header, 0);
curl_setopt ($ch, Curlopt_ssl_verifypeer, false);
$content = curl_exec ($ch);
Var_dump (Curl_error ($ch));
Print_r ($content);
Curl_close ($ch);
?>
PHP Training Curl Emulation Login