WeChat Public Platform message interface check and message interface response instance, check example _php tutorial

Source: Internet
Author: User

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 ...

  • 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.