Skip to content

Instantly share code, notes, and snippets.

@binderclip
Last active March 26, 2018 09:31
Show Gist options
  • Save binderclip/b1b648eea931b7530a105b125e0568cc to your computer and use it in GitHub Desktop.
Save binderclip/b1b648eea931b7530a105b125e0568cc to your computer and use it in GitHub Desktop.
微信服务号请求消息格式
// 本来的数据是 XML 的,手动转换成了 json 格式
// 文本消息
{
"ToUserName": "gh_555555555555",
"FromUserName": "o3QQQQQQQQQQQQQQQQQQQQQQQQQQ",
"CreateTime": "1520247736",
"MsgType": "text",
"Content": "红包",
"MsgId": "6529414308333333333"
}
// 点击菜单拉取消息时的事件推送
{
"ToUserName": "gh_555555555555",
"FromUserName": "o3QQQQQQQQQQQQQQQQQQQQQQQQQQ",
"CreateTime": "1520248367",
"MsgType": "event",
"Event": "CLICK",
"EventKey": "click_test"
}
// 点击菜单跳转链接时的事件推送
{
"ToUserName": "gh_555555555555",
"FromUserName": "o3QQQQQQQQQQQQQQQQQQQQQQQQQQ",
"CreateTime": "1520249183",
"MsgType": "event",
"Event": "VIEW",
"EventKey": "https://example.com",
"MenuId": "442570109"
}
// 关注事件
{
"ToUserName": "gh_555555555555",
"FromUserName": "o3QQQQQQQQQQQQQQQQQQQQQQQQQQ",
"CreateTime": "1520249399",
"MsgType": "event",
"Event": "subscribe",
"EventKey": null
}
// 取消关注事件
{
"ToUserName": "gh_555555555555",
"FromUserName": "o3QQQQQQQQQQQQQQQQQQQQQQQQQQ",
"CreateTime": "1520249343",
"MsgType": "event",
"Event": "unsubscribe",
"EventKey": null
}
// 扫描带参数二维码并关注事件
{
"ToUserName": "gh_555555555555",
"FromUserName": "o3QQQQQQQQQQQQQQQQQQQQQQQQQQ",
"CreateTime": "1520249771",
"MsgType": "event",
"Event": "subscribe",
"EventKey": "qrscene_2", // qrscene_ 是固定前缀
"Ticket": "gQHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH"
}
// 扫描带参数二维码事件(已关注)
{
"ToUserName": "gh_555555555555",
"FromUserName": "o3QQQQQQQQQQQQQQQQQQQQQQQQQQ",
"CreateTime": "1520249672",
"MsgType": "event",
"Event": "SCAN",
"EventKey": "2",
"Ticket": "gQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ"
}
@binderclip
Copy link
Author

MsgType == text // 文本消息
MsgType == event
    Event == CLICK // 点击菜单拉取消息时的事件推送
    Event == VIEW // 点击菜单跳转链接时的事件推送
    Event == subscribe
        EventKey == null // 关注事件
        EventKey != null // 扫描带参数二维码并关注事件
    Event == unsubscribe // 取关事件
    Event == SCAN // 扫描带参数二维码事件(已关注)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment