This paper illustrates the method of message interface checksum and message interface response for micro-trust public platform. Share to everyone for your reference. The specific analysis is as follows:
In the process of developing the message interface of the micro-credit public platform, we first need to verify the validity of the message interface, then we can carry out other development after verification, first we take a look at the micro-trust public platform to my PHP SDK.
1, need to set a TOKEN information, the code is as follows:
Copy Code code as follows:
Efine ("TOKEN", "Weixin");
This TOKEN information can be set by the developer.
2, there is a Wechatcallbackapitest class, the class contains 3 methods: Valid, Responsemsg, Checksignature, where the method valid, Checksignature is used to validate interface URL validity, Responsemsg is the most common method we use, and most of the subsequent development work will be done here.
After we passed the validation of the interface, we no longer need to validate, then we need to use the Responsemsg method, then how to ensure that the interface verification through, do not need to switch the method or modify the code?
That's what I did, the code is as follows:
Copy 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;
}
To explain: Because when validating interface validity passed a echostr parameter, and in the message interface response process does not have this parameter, all we use this parameter to judge is to verify the interface or interface response, the code is as follows:
Copy Code code as follows:
Isset ($_get[' echostr ')
I hope this article will help you with your PHP program design.