个人网站用什么域名好网站asp代码
web/
2025/10/9 9:17:18/
文章来源:
个人网站用什么域名好,网站asp代码,常见的网站结构类型,WordPress潮流媒体主题首先在微信公众平台(网址#xff1a;https://mp.weixin.qq.com)申请一个订阅号#xff0c;然后在开发里找到开发者工具点击公众平台测试账号#xff0c;在测试账号内进行微信开发实验。 1. 设置一个自己的有效的域名网址和TOKEN(就是暗号)#xff0c;TOKEN一定要与PHP代…首先在微信公众平台(网址https://mp.weixin.qq.com)申请一个订阅号然后在开发里找到开发者工具点击公众平台测试账号在测试账号内进行微信开发实验。 1. 设置一个自己的有效的域名网址和TOKEN(就是暗号)TOKEN一定要与PHP代码中的TOKEN验证一致否则会一直配置失败(写有这段代码的文件一定要传到有效的域名网址内。与设置的网址必须相同)。 下面是PHP代码(在微信公众平台开发里的开发者文档内有部分代码) 。//define your tokendefine(TOKEN, weixin);$wechatObj new wechatCallbackapiTest();$wechatObj-run();class wechatCallbackapiTest{public function run(){if ($this-checkSignature()false) {die(非法请求);}if (isset($_GET[echostr])) {$echostr $_GET[echostr];echo $echostr;exit();} else {$this-responseMsg();}/*$echoStr $_GET[echostr];//valid signature , optionif($this-checkSignature()){echo $echoStr;exit;*/}}public function responseMsg(){//get post data, May be due to the different environments$postStr $GLOBALS[HTTP_RAW_POST_DATA];//extract post dataif (!empty($postStr)){$postObj simplexml_load_string($postStr, SimpleXMLElement, LIBXML_NOCDATA);$fromUsername $postObj-FromUserName;$toUsername $postObj-ToUserName;$keyword trim($postObj-Content);$time time();$textTpl %s0;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);$tmpStr implode( $tmpArr );$tmpStr sha1( $tmpStr );if( $tmpStr $signature ){return true;}else{return false;}}}?2.自动回复 首先重新写一个方法在上面那个文件夹里再调用此方法注意不能重名。以下代码是给订阅号发天气它会回复天气晴朗发放假它会回复你“不好好奋斗瞎想啥”回复其他则会回复Welcome to wechat world!public function responseMsg(){//get post data, May be due to the different environments$postStr $GLOBALS[HTTP_RAW_POST_DATA];file_put_contents(msg.txt, $postStr,FILE_APPEND);//extract post dataif (!empty($postStr)){$postObj simplexml_load_string($postStr, SimpleXMLElement, LIBXML_NOCDATA);$fromUsername $postObj-FromUserName;$toUsername $postObj-ToUserName;$keyword trim($postObj-Content);$time time();//$msgType $postObj-MsgType;//消息类型//$event $postObj-Event;//时间类型subscribe(订阅)、unsubscribe(取消订阅)$textTpl %s0;if(!empty( $keyword )){$msgType text;$contentStr $this-autohuifu($keyword);//$contentStr Welcome to wechat world!;$resultStr sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);echo $resultStr;}else{echo Input something...;}}else {echo ;exit;}}public function autohuifu($keyword){if($keyword 天气){$contentStr 天气晴朗;}else if($keyword 放假){$contentStr 成天不好好奋斗瞎想啥;}else{$contentStr Welcome to wechat world!;}return $contentStr;
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/89557.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!