Summary of WeChat public platform development experience and public platform experience

Source: Internet
Author: User

Summary of public platform development experience and public platform experience

I have been developing PHP and. net since last year. I have some tips to share with you.

First, if the deployed server is port 80, it was previously applied for free at the Baidu Developer Center. Later, they paid for the server they applied for at the Sina Developer Center, this type of server can only deploy PHP code. The server of Sina free version does not support ASP.net.

During the connection, the token verification fails. This may be a code issue or a URL issue. We recommend you test the simplest code. below is the PHP code, copy it directly, replace the relevant parameters, test the connection, or sometimes it is a network problem. Use this connection to copy your code.

<?phpdefine("TOKEN", "pondbay");$wechatObj = new wechatCallbackapiTest();$wechatObj->valid();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;        }    }}?>

Later in development, you can use a browser to open the push URL and check whether the returned json is correct. It is best to add a log file to the developed Code to facilitate tracking and error detection.

In addition, there is an error in the interface document. Note that the group message type is mpnews, the text is text, the image is image, the voice is voice, and the music is music, vedio is written in the official video interface documentation, but a type error is reported, which should be mpvedio.

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.