This is a good question, but it is a pity that all of your replies are on paper without discussion. The answer to the top ticket actually says that it is ridiculous to get the packet capture tool, in chrome F12, we can see that the account and password are sent in plaintext. Why should we capture packets? In addition, the http header of the subject is copied from chrome.
How does PHP simulate login using curl?
$ch = curl_init();$url = " $data = array( 'mail' => *** 'password' => ***);foreach ($data as $key => $value){ $postfields .= urlencode($key) . '=' . urlencode($value) . '&';}$postfields = rtrim($postfields, '&');$headers = array( 'Accept:*/*', 'Accept-Encoding:gzip, deflate', 'Accept-Language:zh-CN,zh;q=0.8', 'Connection:keep-alive', 'Content-Length:49', 'Content-Type:application/x-www-form-urlencoded; charset=UTF-8', 'Cookie:mp_18fe57584af9659dea732cf41c1c0416_mixpanel= %7B%22distinct_id%22%3A%20%22153c6c3ec0c91-04fd9c038-12771e2d-1fa400-153c6c3ec0d18a%22%2C%22%24 initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D; PHPSESSID=web2~dom8lkdgosec57oljs98g2m8k0; _gat=1; Hm_lvt_e23800c454aa573c0ccb16b52665ac26=1463986883,1464937399,1465290769,1465713371; Hm_lpvt_e23800c454aa573c0ccb16b52665ac26=1465717067; _ga=GA1.2.1469164019.1455850659', 'Host:segmentfault.com', 'Origin:https://segmentfault.com', 'Referer:https://segmentfault.com/', 'User-Agent:Mozilla/5.0 (X11; Linux i686 (x86_64)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36', 'X-Requested-With:XMLHttpRequest',);curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);curl_setopt($ch, CURLOPT_ENCODING, "");$result = curl_exec($ch);curl_close($ch);var_dump($result);
The returned result indicates that my user or password is incorrect? The account password is correct.
Analysis
This is a good question, but it is a pity that all of your replies are on paper without discussion. The answer to the top ticket actually says that it is ridiculous to get the packet capture tool, in chrome F12, we can see that the account and password are sent in plaintext. Why should we capture packets? In addition, the http header of the subject is copied from chrome.
According to my opinion, the cause of your problem is that too many http headers are sent, and Content-Length is obviously problematic. This indicates the Content Length. Your packet capture is 49 this time, but next time you change your account password, it is not necessarily the case. For example, if the account password is too long, it may be truncated. In any case, a wrong password will be prompted (because only a part of the password has been sent ).
Solution
In fact, to explore this interesting question, I am dedicated to doing an interesting experiment.
Here we use the ajax model in node. js, the simplest scripting language, to rebuild the operation process.
Analysis
Let's go to the login page -- the source code page for a rough look, where