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

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

照著老師的來寫關注后還是沒回復,哪位同學解決的,麻煩指點一下

// 接收事件推送并回復

? ? public function reponseMsg()

? ? {

? ? ? ? $postArr = $GLOBALS['HTTP_RAW_POST_DATA'];


? ? ? ? $postObj = simplexml_load_string($postArr);

? ? ? ??

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

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

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

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

? ? ? ? ? ? ? ? $createTime = 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,$createTime,$msgType,$Content);

? ? ? ? ? ? ? ? echo $info;

? ? ? ? ? ? }

? ? ? ? }

? ? }


正在回答

4 回答

看下php版本 7.0$postArr = $GLOBALS['HTTP_RAW_POST_DATA'];就獲取不到xml了

0 回復 有任何疑惑可以回復我~

還是不行

0 回復 有任何疑惑可以回復我~
public?function?index()
{
????if?(isset($_GET['echostr']))?{
????????//獲得參數?signature?nonce?token?timestamp?echostr
????????$nonce?=?$_GET['nonce'];
????????$token?=?'weixin';
????????$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)?{
????????????//第一次接入weixin?api接口的時候
????????????echo?$echostr;
????????????exit;
????????}
????}?else?{
????????$this->responseMsg();
????}
}

拿去吧 少年

0 回復 有任何疑惑可以回復我~

$content ? 第一個字母大寫了。

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

照著老師的來寫關注后還是沒回復,哪位同學解決的,麻煩指點一下

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

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

幫助反饋 APP下載

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

公眾號

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