This article mainly introduces the methods of Message Interface Verification and message interface response on the public platform. it analyzes the specific steps of public platform development and the usage of wechatCallbackapiTest and other classes, which has some reference value, for more information about how to verify the message interface and respond to the message interface on the public platform, see the following example. Share it with you for your reference. The specific analysis is as follows:
During the development of the public platform message interface, we first need to verify the validity of the message interface. after the verification is passed, we can perform other development. First, let's take a look at the php sdk provided by the public platform to me.
1. you need to set a TOKEN. the code is as follows:
The code is as follows:
Efine ("TOKEN", "weixin ");
The TOKEN information can be set by the developer.
2. there is a wechatCallbackapiTest class that contains three methods: valid, responseMsg, and checkSignature. the methods valid and checkSignature are used to verify the validity of the interface URL, responseMsg is the most widely used method, and most of the subsequent development work will be completed here.
After we pass the interface validation, we no longer need to verify the interface, then we need to use the responseMsg method, then how to ensure that after the interface verification is passed, you don't need to switch the method or modify the code in it?
The code is as follows:
The code is as follows:
Public function indexAction ()
{
If (isset ($ _ GET ['echostr'])
{
$ EchoStr = $ _ GET ["echostr"];
// Valid signature, option
If ($ this-> checkSignatureAction ())
{
Echo $ echoStr;
Exit;
}
}
Else
{
$ This-> responseMsgAction ();
}
Return FALSE;
}
Explanation: an echostr parameter is passed to verify the interface validity, but this parameter is not provided in the response process of the message interface, here we use this parameter to determine whether to verify the interface or interface response. the code is as follows:
The code is as follows:
Isset ($ _ GET ['echostr'])
I hope this article will help you with php programming.