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!