Mini-app message push php Server Verification settings page ("settings"> "development settings "):
Set server domain name
For example: https://hosts.com
Note the differences between http and https protocols.
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 entered in the background
$ WechatObj = new wechatAPI ();
$ WechatObj-> isValid ();
Class wechatAPI
{
Public function isValid () // verification interface. If yes, the echostr parameter sent from it is returned.
{
$ EchoStr = $ _ GET ["echostr"];
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 the details of the php Server Verification for mini-app message push. For more information, see other related articles in the first PHP community!