WeChat mini-app message push php server verification instance details, mini-app php

Source: Internet
Author: User
Tags php server

Small Program message push php server verification instance details, small program php

Details about the php server verification instance for mini-app message push

Documentation (depending on a "access guide"): https://mp.weixin.qq.com/debug/wxadoc/dev/api/custommsg/callback_help.html

Settings page ("Settings"> "development settings "):

Https://mp.weixin.qq.com/wxopen/initprofile? Action = home & lang = zh_CN

1. Set the server Domain Name

For example: https://hosts.com

Note the differences between http and https protocols.

2. Set message push

2.1 Add the server interface test. php to your server. The content of the test. php interface is mainly used to verify whether the message is sent through the token. The code is shown in the official example:

Define ("TOKEN", "xxxxx");/the token $ wechatObj = new wechatAPI (); $ wechatObj-> isValid (); class wechatAPI {public function isValid () // verify the interface. if yes, the echostr parameter {$ echoStr = $ _ GET ["echostr"] is returned. if ($ this-> checkSignature ()) {echo $ echoStr; exit ;}} private function checkSignature () // official verification function {$ signature =$ _ GET ["signature"]; $ timestamp = $ _ GET ["timestamp"]; $ nonce = $ _ GET ["nonce"]; $ token = TOKEN; $ tmpArr = array ($ token, $ timestamp, $ nonce); sort ($ tmpArr, SORT_STRING); $ tmpStr = implode ($ tmpArr); $ tmpStr = sha1 ($ tmpStr); if ($ tmpStr = $ signature) {return true ;}else {return false ;}}};

2.2 set the background message push information of the Applet

URL (server address): https://hosts.com/xx/test.php

Token: Any conforming string, as defined above "xxxxx"

EncodingAESKey (message encryption key): (it is generated randomly and saved on your own. This encryption key is used for decryption)

Message encryption method: Select plaintext for the time being. You do not need to consider encryption and decryption.

Data format: select as needed.

Submit. If there is no problem, it will succeed. (If there is a problem, you can use fake data to test it in a browser)

Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

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.