第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

關(guān)注后沒有回復(fù)呢?

照老師講的寫的,

代碼在這里全部能看到。https://github.com/phpervip/tp5_demo/blob/master/application/index/controller/Wechat.php

// http://tp5.yyii.info/index/wechat/index
class Wechat extends Controller
{
? ?public function index(){

? ? ? ?//獲得參數(shù) signature nonce token timestamp echostr
? ? ? ?$nonce ? ? = $_GET['nonce'];
? ? ? ?$token ? ? = 'weixin';
? ? ? ?$timestamp = $_GET['timestamp'];
? ? ? ?$echostr ? = $_GET['echostr'];
? ? ? ?$signature = $_GET['signature'];
? ? ? ?//形成數(shù)組,然后按字典序排序
? ? ? ?$array = array();
? ? ? ?$array = array($nonce, $timestamp, $token);
? ? ? ?sort($array);
? ? ? ?//拼接成字符串,sha1加密 ,然后與signature進(jìn)行校驗
? ? ? ?$str = sha1( implode( $array ) );
? ? ? ?if( $str ?== $signature && $echostr ){
? ? ? ? ? ?//第一次接入weixin api接口的時候
? ? ? ? ? ?echo ?$echostr;
? ? ? ? ? ?exit;
? ? ? ?}else{
? ? ? ? ? ?$this->reponseMsg();
? ? ? ?}
? ?}

// http://tp5.yyii.info/index/wechat/show
? ?public function show(){
? ? ? ?echo 'this is show';
? ?}

? ?// 接收事件推送并回復(fù)
? ?public function reponseMsg(){
? ? ? ?//1.獲取到微信推送過來post數(shù)據(jù)(xml格式)
? ? ? ?$postArr = $GLOBALS['HTTP_RAW_POST_DATA'];
? ? ? ?//2.處理消息類型,并設(shè)置回復(fù)類型和內(nèi)容
? ? ? ?$postObj = simplexml_load_string( $postArr );
? ? ? ?//判斷該數(shù)據(jù)包是否是訂閱的事件推送
? ? ? ?if( strtolower( $postObj->MsgType) == 'event'){
? ? ? ? ? ?//如果是關(guān)注 subscribe 事件
? ? ? ? ? ?if( strtolower($postObj->Event == 'subscribe') ){
? ? ? ? ? ? ? ?//回復(fù)用戶消息(純文本格式)
? ? ? ? ? ? ? ?$toUser ? = $postObj->FromUserName;
? ? ? ? ? ? ? ?$fromUser = $postObj->ToUserName;
? ? ? ? ? ? ? ?$time ? ? = time();
? ? ? ? ? ? ? ?$msgType ?= ?'text';
? ? ? ? ? ? ? ?$content ?= '歡迎關(guān)注我們的微信公眾賬號'.$postObj->FromUserName.'-'.$postObj->ToUserName;
? ? ? ? ? ? ? ?$template = "<xml>
? ? ? ? ? ? ? ? ? ? <ToUserName><![CDATA[%s]]></ToUserName>
? ? ? ? ? ? ? ? ? ? <FromUserName><![CDATA[%s]]></FromUserName>
? ? ? ? ? ? ? ? ? ? <CreateTime>%s</CreateTime>
? ? ? ? ? ? ? ? ? ? <MsgType><![CDATA[%s]]></MsgType>
? ? ? ? ? ? ? ? ? ? <Content><![CDATA[%s]]></Content>
? ? ? ? ? ? ? ? ? ? </xml>";
? ? ? ? ? ? ? ?$info ? ? = sprintf($template, $toUser, $fromUser, $time, $msgType, $content);
? ? ? ? ? ? ? ?echo $info;

? ? ? ? ? ?}
? ? ? ?}


正在回答

1 回答

我也是這個問題

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
PHP實現(xiàn)微信公眾平臺開發(fā)—提升篇
  • 參與學(xué)習(xí)       64947    人
  • 解答問題       341    個

本課程詳細(xì)講解了接收微信用戶發(fā)送的消息和接收訂閱關(guān)注的事件推送

進(jìn)入課程

關(guān)注后沒有回復(fù)呢?

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號