Home >WeChat Applet >Mini Program Development >How to set WeChat applet URL and token
This article mainly introduces relevant information on the detailed explanation of WeChat applet URL and token settings. I hope this article can help everyone solve similar problems. Friends in need can refer to it. I hope it can help everyone.
Detailed explanation of WeChat applet 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 above to obtain The url and set token will automatically generate EncodingASEKey
Setting completed
Related recommendations:
Node.js access_token implements WeChat access and refresh examples
Vue uses token to jump to the login page after expiration
The above is the detailed content of How to set WeChat applet URL and token. For more information, please follow other related articles on the PHP Chinese website!