首頁 >微信小程式 >微信開發 >微信公眾號開發微信的訊息類型解析

微信公眾號開發微信的訊息類型解析

高洛峰
高洛峰原創
2017-03-09 15:36:282195瀏覽

這篇文章一起了解微信公眾號開發微信的訊息類型解析

當普通微信用戶向公眾帳號發送訊息時,微信伺服器將POST訊息的XML封包到開發者填寫的URL上。各訊息類型的推送XML封包結構如下。

#6

目錄

[隱藏]

  • ##1 文字訊息

  • #2 圖片訊息

  • #3 語音訊息

  • #4 視訊訊息

  • #5 地理位置訊息

連結訊息

#文字訊息
 <xml>
 <tousername></tousername>
 <fromusername></fromusername> 
 <createtime>1348831860</createtime>
 <msgtype></msgtype>
 <content></content>
 <msgid>1234567890123456</msgid>
 </xml>
開發者微訊號傳送方帳號(一個OpenID)訊息建立時間(整數)text文字訊息內容
參數描述
ToUserName
FromUserName
#CreateTime
MsgType
Content

MsgId

訊息id,64位元整數

#使用網頁偵錯工具來偵錯該介面
 <xml>
 <tousername></tousername>
 <fromusername></fromusername>
 <createtime>1348831860</createtime>
 <msgtype></msgtype>
 <picurl></picurl>
 <mediaid></mediaid>
 <msgid>1234567890123456</msgid>
 </xml>
參數##ToUserName開發者微訊號發送方帳號(一個OpenID)訊息建立時間(整數)
##圖片訊息
#描述
FromUserName
CreateTime

MsgType

#image

PicUrl#圖片連結MediaId圖片訊息媒體id,可以呼叫多媒體檔案下載介面拉取資料。 MsgId訊息id,64位元整數使用網頁偵錯工具偵錯該介面
<xml>
<tousername></tousername>
<fromusername></fromusername>
<createtime>1357290913</createtime>
<msgtype></msgtype>
<mediaid></mediaid>
<format></format>
<msgid>1234567890123456</msgid>
</xml>
#參數描述
語音訊息

ToUserName開發者微訊號

#FromUserName傳送方帳號(一個OpenID)CreateTime訊息建立時間(整數)#MsgType##語音為voice語音訊息媒體id,可以呼叫多媒體檔案下載介面拉取資料。 語音格式,如amr,speex等訊息id,64位元整數使用網頁偵錯工具偵錯該介面#視訊訊息##
<xml>
<tousername></tousername>
<fromusername></fromusername>
<createtime>1357290913</createtime>
<msgtype></msgtype>
<mediaid></mediaid>
<thumbmediaid></thumbmediaid>
<msgid>1234567890123456</msgid>
</xml>
參數描述
#MediaId
Format
MsgID

ToUserName

開發者微訊號

FromUserName傳送方帳號(一個OpenID)CreateTime訊息建立時間(整數) 影片為video#MediaId視訊訊息媒體id,可以呼叫多媒體文件下載介面拉取資料。 ThumbMediaId視訊訊息縮圖的媒體id,可以呼叫多媒體檔案下載介面拉取資料。 MsgId訊息id,64位元整數
<xml>
<tousername></tousername>
<fromusername></fromusername>
<createtime>1351776360</createtime>
<msgtype></msgtype>
<location_x>23.134521</location_x>
<location_y>113.358803</location_y>
<scale>20</scale>
<label></label>
<msgid>1234567890123456</msgid>
</xml>
#參數描述##ToUserName微訊號#FromUserName
MsgType
使用網頁偵錯工具偵錯該介面
地理位置訊息
開發者
###傳送方帳號(一個OpenID)## ##########CreateTime######訊息建立時間(整型)############MsgType######location####### ######Location_X######地理位置維度############Location_Y######地理位置精確度##############Location_Y######地理位置精確度############################################################################################################################################################################' Scale######地圖縮放大小############Label#######地理位置資訊############MsgId##### #訊息id,64位元整數############

使用网页调试工具调试该接口

链接消息

<xml>
<tousername></tousername>
<fromusername></fromusername>
<createtime>1351776360</createtime>
<msgtype></msgtype>
<title></title>
<description></description>
<url></url>
<msgid>1234567890123456</msgid>
</xml>
参数 描述
ToUserName 接收方微信号
FromUserName 发送方微信号,若为普通用户,则是一个OpenID
CreateTime 消息创建时间
MsgType 消息类型,link
Title 消息标题
Description 消息描述
Url 消息链接
MsgId 消息id,64位整型

使用网页调试工具调试该接口


以上是微信公眾號開發微信的訊息類型解析的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn