Public platform message interface validation and message interface response instances, verifying instances
This paper describes the method of public platform message interface check and message interface response. Share to everyone for your reference. The specific analysis is as follows:
In the process of developing the public platform message interface, we first need to verify the validity of the message interface, the validation passed before we can do other development, first we look at the public platform to my PHP SDK.
1, need to set up a TOKEN information, the code is as follows:
Copy the Code code as follows: Efine ("TOKEN", "Weixin");
This TOKEN information can be set by the developer itself.
2, there is a Wechatcallbackapitest class, the class contains 3 methods: Valid, Responsemsg, Checksignature, wherein the method valid, Checksignature is used to verify the validity of the interface URL, Responsemsg is the most common method we use, and most of the subsequent development work will be done here.
After we pass the validation of the interface, it is no longer necessary to validate, then we need to use the Responsemsg method, then how to ensure that the interface validation through, do not need to switch the method or modify the code in it?
This is what I did, the code is as follows:
Copy the Code Code 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;
}
Explain: Because the interface validation is passed a echostr parameter, and in the message interface response process does not have this parameter, all of us here with this parameter to determine whether to verify the interface or interface response, the code is as follows:
Copy the Code code as follows: Isset ($_get[' echostr ')
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/932076.html www.bkjia.com true http://www.bkjia.com/PHPjc/932076.html techarticle Public Platform Message interface check and message interface Response example, the example of this paper describes the public platform message interface check and message interface response method. Share to everyone ...