This time the Platform home page login logic will often appear unable to log in state, a few days ago wrote a crawl verification code required user input, this does not have to do how much code adjustment, mainly
Let the front end write a JS directly call the micro-letter public Platform Verification Code connection, found no, two aspects:
1, Imgcode This table single-name the wrong call
2, in the grasp of the bag when suddenly found to get the authentication code connection has set cookies
After discovering the problem, these are not big things, code code loose solution:
Public Function Getimgcode ($username) {
$str = $this-> getcurl ()-> Get ("Https://mp.weixin.qq.com/cgi-bin/verifycode?username=". $username. " &r= ". Time ())->execute ();
Header (' Content-type:image/jpeg ');
Echo $str;
}
First Use Curl to request the authentication code, in the way to save cookies, of course, here I have a simple package of curl, and then directly to the output crawl to the content, output header
PS: Here is a problem, in fact, is not what the problem, may often be noticed, in the test when found that there is a warning error, the tip has been sent to the head. I'm just so depressed.
Output directly in the code, why does this happen? File is also utf-8 no BOM header format, down a pull only to find that the current class library has written?> this thing, there is just a blank line behind.
In fact, the focus is not here, because even if the end of the file has a blank line will not prompt the head has been sent AH. Direct analysis to the Curl class file, OK, sure enough, this file is written again?> shit!!!
Original from: http://www.mapenggang.com/