接收事件推送

跳转到: 导航, 搜索

微博会把用户关注/取消关注第三方微博账号,扫描带参数二维码等事件推送到第三方微博账号在粉丝服务后台填写的URL。方便开发者给用户下发欢迎消息或者做帐号的解绑。

微博服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次。

关于重试的消息排重,推荐使用FromUserName + CreateTime 排重。

假如服务器无法保证在五秒内处理并回复,可以直接回复空串,微博服务器不会对此作任何处理,并且不会发起重试。

目录

关注/取消关注事件

关注/取消关注事件,推送的JSON格式如下:

{
    "type": "event",
    "receiver_id": 1902538057,
    "sender_id": 2489518277,
    "created_at": "Mon Jul 16 18:09:20 +0800 2012",
    "text": "关注事件消息",
    "data": {
        "subtype": "follow"
    }
}
返回值说明
属性 值的类型 说明描述
type string event
receiver_id int64 消息的接收者
sender_id int64 消息的发送者
created_at string 消息创建时间
text string 默认文案。subtype为follow或unfollow时分别为“关注事件消息”、“取消关注事件消息”;
data string 消息内容
data:subtype string follow:关注事件,unfollow取消关注事件。

订阅/取消订阅事件

订阅/取消订阅事件,推送的JSON格式如下:

{
    "type": "event",
    "receiver_id": 1902538057,
    "sender_id": 2489518277,
    "created_at": "Mon Jul 16 18:09:20 +0800 2012",
    "text": "订阅事件消息",
    "data": {
        "subtype": "subscribe"
    }
}
返回值说明
属性 值的类型 说明描述
type string event
receiver_id int64 消息的接收者
sender_id int64 消息的发送者
created_at string 消息创建时间
text string 默认文案。为subscribe或unsubscribe时为触发订阅的私信关键词(如“dy”),非私信触发时(点击订阅按钮)为“订阅事件消息”、“取消订阅事件消息”;
data string 消息内容
data:subtype string subscribe订阅事件,unsubscribe订阅事件。


扫描带参数二维码事件

扫描带参数二维码事件,推送的JSON格式如下:

{
    "type": "event",
    "receiver_id": 1902538057,
    "sender_id": 2489518277,
    "created_at": "Mon Jul 16 18:09:20 +0800 2012",
    "text": "扫描二维码",
    "data": {
        "subtype": "scan_follow",
        "key": "action_name_scene_id",
        "ticket": "TICKET",
    }
}
返回值说明
属性 值的类型 说明描述
type string event
receiver_id int64 消息的接收者
sender_id int64 消息的发送者
created_at string 消息创建时间
text string 默认文案。subtype为scan或scan_follow时为“扫描二维码”;
data string 消息内容
data:subtype string scan和scan_follow为二维码扫描事件。
data:key string 事件KEY值,格式为action_name_scene_id,也就是说以action_name为前缀,后面为二维码的scene_id;
data:ticket string 二维码的ticket,可用来换取二维码图片。


被@消息

说明:指定的认证用户需被授予接收“被@消息”权限,此接口才返回“被@消息”,申请可邮件 jingyi7@staff.weibo.com

{
    "type": "mention",
    "receiver_id": 1902538057,
    "sender_id": 2489518277,
    "created_at": "Mon Jul 16 18:09:20 +0800 2012",
    "text": "被@的微博或评论文本信息",
    "data": {
        "subtype": "MENTION_TYPE,
        "key": "MENTION_KEY"
    }
}

// 默认仅返回可信用户的@,如需返回所有用户@,认证用户可访问此链接设置:http://account.weibo.com/set/message
返回值说明
属性 值的类型 说明描述
type string mention
receiver_id int64 消息的接收者
sender_id int64 消息的发送者
created_at string 消息创建时间
text string 被@的微博或评论文本信息
data string 消息内容
data:subtype string status:@的微博,comment:@的评论
data:key string 当subtype为status时为微博ID,为comment时为评论ID

点击菜单拉取消息时的事件推送

点击Click菜单事件,推送的JSON格式如下:

{
    "type": "event",
    "receiver_id": 1902538057,
    "sender_id": 2489518277,
    "created_at": "Mon Jul 16 18:09:20 +0800 2012",
    "text": "自定义菜单点击事件消息",
    "data": {
        "subtype": "click",
        "key": "EVENT_KEY"
    }
}
返回值说明
属性 值的类型 说明描述
type string event
receiver_id int64 消息的接收者
sender_id int64 消息的发送者
created_at string 消息创建时间
text string 默认文案,subtype为click时为 "自定义菜单点击事件消息";
data string 消息内容
data:subtype string click, 自定义菜单点击事件
data:key string 被点击的自定义菜单的key值


点击菜单跳转链接时的事件推送

点击View菜单事件,推送的JSON格式如下:

{
    "type": "event",
    "receiver_id": 1902538057,
    "sender_id": 2489518277,
    "created_at": "Mon Jul 16 18:09:20 +0800 2012",
    "text": "自定义菜单跳转链接事件消息",
    "data": {
        "subtype": "view",
        "key": "url"
    }
}
返回值说明
属性 值的类型 说明描述
type string event
receiver_id int64 消息的接收者
sender_id int64 消息的发送者
created_at string 消息创建时间
text string 默认文案,subtype为view时为 "自定义菜单跳转链接事件消息";
data string 消息内容
data:subtype string view, 自定义菜单跳转链接事件消息
data:key string 该按钮设置的url
文档更新时间: 2015-10-28