Home >WeChat Applet >Mini Program Development >About the settings of WeChat applet URL and token
This article mainly introduces the relevant information on the detailed explanation of the URL and token settings of the WeChat applet. I hope this article can help everyone solve similar problems. Friends in need can refer to the following
WeChat applet Detailed explanation of url and token settings
Create a weixin.php file in the code of Sina Cloud Application sae and write the following code
define("TOKEN","myToken");// 后台填写的token,在微信公众平台启用 $wechatObj = new wechatAPI(); $wechatObj->isValid(); class wechatAPI { public function isValid()//验证微信接口,验证函数以外的代码和微信公众号开发token设置相同 { $echoStr = $_GET["echostr"]; if ($this->checkSignature()) { header('content-type:text');//add,一定要加入header echo $echoStr; exit; } } private function checkSignature() //官方的验证函数 { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = TOKEN; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr, SORT_STRING); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $tmpStr == $signature ){ return true; }else{ return false; } } };
After saving, access via url, copy the url in the address bar, and write it into the WeChat public platform
In the development settings of the WeChat public platform, fill in the url obtained above and The set token will automatically generate EncodingASEKey
Setting completed
The above is the entire content of this article, I hope it will be helpful to everyone Learning is helpful. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
Analysis of binding click events in WeChat Mini Program
The post method in WeChat Mini Program and Encapsulation of get method
Method of using ECharts to asynchronously load data in WeChat applet
The above is the detailed content of About the settings of WeChat applet URL and token. For more information, please follow other related articles on the PHP Chinese website!