Home  >  Article  >  WeChat Applet  >  WeChat public account development WeChat message type analysis

WeChat public account development WeChat message type analysis

高洛峰
高洛峰Original
2017-03-09 15:36:282041browse

In this article, let’s learn about the message type analysis of WeChat public account development

When an ordinary WeChat user sends a message to the public account, the WeChat server will POST the XML data packet of the message to the URL filled in by the developer. . The push XML data packet structure of each message type is as follows.

##Text message

##Table of Contents

[Hide]

  • 1 Text message

  • 2 Picture message

  • 3 Voice message

  • ##4

    Video message

  • 5

    Geolocation message

  • ##6
  • Link message

 <xml>
 <ToUserName><![CDATA[toUser]]></ToUserName>
 <FromUserName><![CDATA[fromUser]]></FromUserName> 
 <CreateTime>1348831860</CreateTime>
 <MsgType><![CDATA[text]]></MsgType>
 <Content><![CDATA[this is a test]]></Content>
 <MsgId>1234567890123456</MsgId>
 </xml>

ParameterDescriptionDeveloperSender account (an OpenID)Message creation time (integer)textText message contentMessage id, 64-bit integerUse web debugging tool to debug this interface
ToUserName
WeChat ID FromUserName
CreateTime
MsgType
Content
MsgId

Picture message

 <xml>
 <ToUserName><![CDATA[toUser]]></ToUserName>
 <FromUserName><![CDATA[fromUser]]></FromUserName>
 <CreateTime>1348831860</CreateTime>
 <MsgType><![CDATA[image]]></MsgType>
 <PicUrl><![CDATA[this is a url]]></PicUrl>
 <MediaId><![CDATA[media_id]]></MediaId>
 <MsgId>1234567890123456</MsgId>
 </xml>

ParametersDescriptionDeveloperSender account (an OpenID)Message creation time (integer)image Picture link Picture message media id, you can call the multimedia file download interface to pull the data. Message id, 64-bit integerUse web debugging tool to debug this interface
ToUserName
WeChat ID FromUserName
CreateTime
MsgType
PicUrl
MediaId
MsgId

Voice message

<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1357290913</CreateTime>
<MsgType><![CDATA[voice]]></MsgType>
<MediaId><![CDATA[media_id]]></MediaId>
<Format><![CDATA[Format]]></Format>
<MsgId>1234567890123456</MsgId>
</xml>

ParametersDescriptionDeveloperSender account (an OpenID)Message creation time (integer)Voice is voiceVoice message media id, you can call the multimedia file download interface to pull the data. Voice format, such as amr, speex, etc.Message id, 64 Bit integerUse web debugging tools to debug this interface
ToUserName
WeChat ID FromUserName
CreateTime
MsgType
MediaId
Format
MsgID

Video message

<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1357290913</CreateTime>
<MsgType><![CDATA[video]]></MsgType>
<MediaId><![CDATA[media_id]]></MediaId>
<ThumbMediaId><![CDATA[thumb_media_id]]></ThumbMediaId>
<MsgId>1234567890123456</MsgId>
</xml>

ParametersDescriptionDeveloperSender account (an OpenID) Message creation time (integer) Video is videoVideo message media id, you can call multimedia files The download interface pulls data. The media id of the video message thumbnail, you can call the multimedia file download interface to pull the data. Message id, 64-bit integerUse web debugging tool to debug this interface
ToUserName
微信 FromUserName
CreateTime
MsgType
MediaId
ThumbMediaId
MsgId

Geolocation message

<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1351776360</CreateTime>
<MsgType><![CDATA[location]]></MsgType>
<Location_X>23.134521</Location_X>
<Location_Y>113.358803</Location_Y>
<Scale>20</Scale>
<Label><![CDATA[位置信息]]></Label>
<MsgId>1234567890123456</MsgId>
</xml>

ParametersDescriptionDeveloperSender account (an OpenID)Message creation time (integer)##MsgTypelocationLocation_XGeolocation dimensionLocation_YGeolocation accuracy ScaleMap zoom sizeLabelGeolocation informationMsgIdMessage id, 64-bit integer type

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

链接消息

<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1351776360</CreateTime>
<MsgType><![CDATA[link]]></MsgType>
<Title><![CDATA[公众平台官网链接]]></Title>
<Description><![CDATA[公众平台官网链接]]></Description>
<Url><![CDATA[url]]></Url>
<MsgId>1234567890123456</MsgId>
</xml>
ToUserName
WeChat ID FromUserName
CreateTime
参数 描述
ToUserName 接收方微信号
FromUserName 发送方微信号,若为普通用户,则是一个OpenID
CreateTime 消息创建时间
MsgType 消息类型,link
Title 消息标题
Description 消息描述
Url 消息链接
MsgId 消息id,64位整型

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


The above is the detailed content of WeChat public account development WeChat message type analysis. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn