This article mainly introduces the details of the php Server Verification instance for pushing messages to applets, for more information, see the next article. This article describes the details of the php Server Verification instance for pushing small program messages. For more information, see
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)
The above is a detailed description of the php Server Verification instance for mini-app message push. For more information, see other related articles in the first PHP community!