亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

求大家幫助,關注還是沒有回復消息呢

<?php

// 本類由系統自動生成,僅供測試用途

class IndexAction extends Action {

? ? public function index(){

? $nonce=$_GET['nonce'];

? $token='wtl';

? $timestamp=$_GET['timestamp'];

? $echostr=$_GET['echostr'];

? $signature=$_GET['signature'];

//形成數組,然后按字典序排序

$array=array();

$array=array($nonce,$timestamp,$token);

sort($array);

//拼接成字符串,sha1加密,然后與signature進行檢驗

$str=sha1(implode($array));

if($str==$signature&&$echostr)

{

header('content-type:text');

//第一次接入微信API接口時候驗證合法性

echo $echostr;

exit;

}

? ? ?else

{

this->responseMsg();

}


}



//接收事件推送回復

? ? ? public function responseMsg()

{

//1.獲取到微信推送過來post數據(xml格式)

$postArr=$GLOBALS['HTTP_RAW_POST_DATA'];

//2.處理消息類型,并設置回復類型和內容

$postObj=simplexml_load_string($postArr);

? ? ? ? //判斷該數據包是否是訂閱de事件推送

? ? ? ? if(strtolower($postObj->MsgType)=='event')

? ? ? ? {

? ? ? ? //如果是關注 subscribe事件

? ? ? ? if(strtolower($postObj->Event)=='subscribe')

? ? ? ? {

? ? ? ? $toUser ? ?=$postObj->FromUserName;

? ? ? ? $fromUser ?=$postObj->ToUserName;

? ? ? ? $time ? ? ?=time();

? ? ? ? $msgType ? ='text';

? ? ? ? $content ? ='歡迎關注我的微信公眾號!';

? ? ? ? $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 回答

終于找到了

this->responseMsg();

少了$

1 回復 有任何疑惑可以回復我~
#1

慕粉3809271 提問者

非常感謝!非常感謝!
2016-12-19 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

求大家幫助,關注還是沒有回復消息呢

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號