Authentication code acquisition of micro-credit public platform analog login

Source: Internet
Author: User
Tags curl

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.