WeChat into the pit first play WeChat public number first Twitter WeChat public WeChat public number the first article

Source: Internet
Author: User
Tags sha1 sha1 encryption
Verification principle:

Signature: Encrypted signature, signature combined with the developer's token parameters and timestamp parameters in the request, nonce parameters.

which

Timestamp: Time stamp

Nonce: Random number

echostr: Random string
1. The token, timestamp, nonce three parameters are ordered in dictionary order.

2. Stitch three parameters into a string and use SHA1 encryption.

3. The developer compares the encrypted string to the signature, and if it is the same, the request comes from, and is trustworthy.

  
   Valid (); Class Wechat{public function valid () {$echoStr = $_get[' Echostr '];if ($this->checksignature ()) {echo $ Echostr;exit;}} Calibration method Private Function Checksignature () {$signature = $_get[' signature '); $timestamp = $_get[' timestamp ']; $nonce = $_get [' nonce ']; $token = token; $tmpArr = Array ($token, $timestamp, $nonce); sort ($TMPARR); $tmpStr = implode ($TMPARR); $tmpStr = SHA1 ($TMPSTR); if ($tmpStr = = $signature) {return true;} Else{return false;}}}

The above describes the first bomb into the pit, including, the first aspect of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.