### [如何对微信公众号基本配置](https://www.prosaas.cn/article/16971) **Published:** 2019-04-26T06:54:08 **Author:** 5201314 **Excerpt:** 本篇文章主要讲述了如何对微信公众号进行基本的配置,具有一定的参考价值,想要搭建微信公众号的朋友可以了解一下,希… 本篇文章主要讲述了如何对微信公众号进行基本的配置,具有一定的参考价值,想要搭建微信公众号的朋友可以了解一下,希望对你有所帮助。   这个是微信公众平台上的配置。 ![](https://img.php.cn/upload/article/000/000/031/abeb864f9e02c9fe1034806b5329ef17-0.png) 这边的url值要直接点到文件上,不然不会成功.   然后后台的设置 valid(); class Wx2 extends Controller { public function index() { $echoStr = $\_GET\["echostr"\]; //valid signature , option if($this->checkSignature()){ ob\_clean(); //丢弃缓存中的内容 echo $echoStr; exit; } } public function responseMsg() { //get post data, May be due to the different environments $postStr = $GLOBALS\["HTTP\_RAW\_POST\_DATA"\]; //extract 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 0 "; if(!empty( $keyword )) { $msgType = "text"; $contentStr = "Welcome to wechat world!"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; }else{ echo "Input something..."; } }else { echo ""; exit; } } private function checkSignature() { $signature = $\_GET\["signature"\]; $timestamp = $\_GET\["timestamp"\]; $nonce = $\_GET\["nonce"\]; $token = TOKEN; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr,SORT\_STRING); 72 $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $tmpStr == $signature ){ return true; }else{ return false; } } } 相关教程:微信公众平台开发视频教程 以上就是如何对微信公众号基本配置的详细内容,更多请关注知企PROSAAS其它相关文章! **Categories:** 后端开发 ---