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.
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.
This document describes how to verify the message interface and respond to the message interface on the public platform. 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 which 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.