Message interface verification and message interface response instance _php techniques for micro-trust public platform

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.