消息

公共属性

除了 UnknownMessage, 每一种 Message 都包括以下属性:

name value
id 消息id,64位整型 [2]
target 开发者账号( OpenID )
source 发送方账号( OpenID )
time 信息发送的时间,一个UNIX时间戳。
raw 信息的原始 XML 格式

TextMessage

TextMessage的属性:

name value
type ‘text’
content 信息的内容

ImageMessage

ImageMessage的属性:

name value
type ‘image’
img 图片网址。你可以从这个网址下到图片

LinkMessage

name value
type ‘link’
title 消息标题
description 消息描述
url 消息链接

LocationMessage

LocationMessage的属性:

name value
type ‘location’
location 一个元组。(纬度, 经度)
scale 地图缩放大小
label 地理位置信息

EventMessage

EventMessage的属性:

name value
type ‘subscribe’ ‘unsubscribe’ ‘click’ 或 ‘location’ [1]
key 事件 key 值。当 type = ‘click’ 时存在。
Latitude 地理位置纬度。当 type = ‘location’ 时存在。
Longitude 地理位置经度。当 type = ‘location’ 时存在。
Precision 地理位置精度。当 type = ‘location’ 时存在。

VoiceMessage

VoiceMessage的属性:

name value
type ‘voice’
media_id 消息媒体 ID
format 声音格式
recognition 语音识别结果

VideoMessage

VideoMessage:

UnknownMessage

UnknownMessage的属性:

name value
type ‘unknown’
raw 请求的正文部分。标准的XML格式。

Note

如果你不为 WeRoBot 贡献代码,你完全可以无视掉 UnknownMessage 。在正常的使用中,WeRoBot应该不会收到 UnknownMessage ——除非 WeRoBot 停止开发。

[1]当你被用户关注时,会收到 type=’subscribe’ 的事件; 被取消关注时是 type=’unsubscribe’ 。当用户点击自定义菜单按钮时 type 为 click ,用户上报地理位置的数据包 type 为 location
[2]截至目前( 2013.03.16 ),微信机器人所收到的消息中都不包含 MsgID.

Table Of Contents

Related Topics