微信開放平臺開發須要注意的問題

一、全網發佈檢測須要注意:返回的普通文本消息「 不能夠加密 」,否側不會經過檢測。小程序

/**
* [responseText 回覆文本消息]
* @param [type] $postObj [description] 接收到的對象
* @param [type] $content [description] 回覆內容
* @return [type] [description]
*/
protected function responseText ( $postObj,$content ) {微信

$template ="<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<Content><![CDATA[%s]]></Content>
</xml>";
$fromUser = $postObj ->ToUserName;
$toUser = $postObj ->FromUserName;
$time = time();
$msgType = 'text';
$res =sprintf($template,$toUser,$fromUser,$time,$msgType,$content);post

echo $res;

}加密

2.unionid 的獲取spa

根據微信官方文檔的說法,同一個開放平臺帳號下的相同主體的小程序或公衆號擁有相同的unionid。那麼,在不可能要求客戶本身去建個開放平臺帳戶的狀況下,就只能由第三方來代替xml

受權的小程序或公衆號來經過接口建立。而這個接口微信開放平臺是提供了的,不過位置有點坑,在待開發公衆號裏面:對象

微信開放平臺帳號管理:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1498704804_iARAL&token=&lang=zh_CNblog

相關文章
相關標籤/搜索