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.