WeChat public platform Message Interface development enable interface

Source: Internet
Author: User
In this public platform development tutorial, we assume that you already have PHP language programs, MySQL databases, computer network communication, and HTTPXMLCSSJS. In this public platform development tutorial, we assume that you already have the PHP language program, MySQL database, computer network communication, and HTTP/XML/CSS/JS basics.

We will use the public account Fang times studio as an example. the QR code can be found at the bottom.

This series of tutorials will guide you through the following tasks:

  1. Apply for resources on the Baidu Cloud Platform

  2. Enable public platform development mode


Article 1 Apply for server resources

Create a Baidu Cloud Application

Apply for an account

Log on to the http://developer.baidu.com/bae, use your mailbox or phone to register an account, registration needs to be bound to a mobile phone and verify the mailbox at the same time.

Create an application

Click

 valid();}else{    $wechatObj->responseMsg();}class wechatCallbackapiTest{    public function valid()    {        $echoStr = $_GET["echostr"];        if($this->checkSignature()){            echo $echoStr;            exit;        }    }    private function checkSignature()    {        $signature = $_GET["signature"];        $timestamp = $_GET["timestamp"];        $nonce = $_GET["nonce"];        $token = TOKEN;        $tmpArr = array($token, $timestamp, $nonce);        sort($tmpArr);        $tmpStr = implode( $tmpArr );        $tmpStr = sha1( $tmpStr );        if( $tmpStr == $signature ){            return true;        }else{            return false;        }    }    public function responseMsg()    {        $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];        if (!empty($postStr)){            $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);            $fromUsername = $postObj->FromUserName;            $toUsername = $postObj->ToUserName;            $keyword = trim($postObj->Content);            $time = time();            $textTpl = "
                         
  %s
                          
  %s
                          
  
   %s
                          
  %s
                          
  %s
                          
  
   0
                          
 ";            if($keyword == "?" || $keyword == "?")            {                $msgType = "text";                $contentStr = date("Y-m-d H:i:s",time());                $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);                echo $resultStr;            }        }else{            echo "";            exit;        }    }}?>


And then compress it into ZIP format, not RAR format

URL:     http://pondbay.duapp.comToken:  pondbay


Enter as shown in,

So far, your public platform account has automatically responded.

For more articles about enabling APIs for Message Interface development on the public platform, refer to PHP Chinese network!

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.