Event
Back

From WeChat Official Account Admin Platform
Jump to: navigation, search

Clicking a clickable custom-defined menu causes WeChat to push the click event to the developer. Clicking a view-only menu redirects the event to the URL but does not push.

Contents

Pulling a Message Event

An example of pushing an XML packet is as follows:

<xml>
    <ToUserName><![CDATA[toUser]]></ToUserName>
    <FromUserName><![CDATA[FromUser]]></FromUserName>
    <CreateTime>123456789</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[CLICK]]></Event>
    <EventKey><![CDATA[EVENTKEY]]></EventKey>
</xml>

Parameter Description

Parameter Description
ToUserName Developer's WeChat ID
FromUserName Sender's WeChat ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Event
Event CLICK
EventKey Event KEY value: corresponds to the KEY value in the custom-defined menu API

URL Redirection Event

An example of pushing an XML packet is as follows:

<xml>
    <ToUserName><![CDATA[toUser]]></ToUserName>
    <FromUserName><![CDATA[FromUser]]></FromUserName>
    <CreateTime>123456789</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[VIEW]]></Event>
    <EventKey><![CDATA[www.qq.com]]></EventKey>
</xml>

Parameter Description

Parameter Description
ToUserName Developer's WeChat ID
FromUserName Sender's WeChat ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Event
Event VIEW
EventKey Event key value: set to the URL to be redirected to

scancode_push: Scanning Event

An example of pushing an XML packet is as follows:

<xml>
    <ToUserName><![CDATA[gh_e136c6e50636]]></ToUserName>
    <FromUserName><![CDATA[oMgHVjngRipVsoxg6TuX3vz6glDg]]></FromUserName>
    <CreateTime>1408090502</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[scancode_push]]></Event>
    <EventKey><![CDATA[6]]></EventKey>
    <ScanCodeInfo><ScanType><![CDATA[qrcode]]></ScanType>
    <ScanResult><![CDATA[1]]></ScanResult>
    </ScanCodeInfo>
</xml>

Parameter Description

Parameter Description
ToUserName Developer's WeChat ID
FromUserName Sender's WeChat ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Event
Event scancode_push
EventKey Event key value, set by developer during menu creation
ScanCodeInfo Content scanned
ScanType Scanning type: qrcode (in normal cases)
ScanResult Scanning result: string corresponding to the QR code

scancode_waitmsg: Scanning and Popping up "receiving message" Event

An example of pushing an XML packet is as follows:

<xml><ToUserName><![CDATA[gh_e136c6e50636]]></ToUserName>
    <FromUserName><![CDATA[oMgHVjngRipVsoxg6TuX3vz6glDg]]></FromUserName>
    <CreateTime>1408090606</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[scancode_waitmsg]]></Event>
    <EventKey><![CDATA[6]]></EventKey>
    <ScanCodeInfo><ScanType><![CDATA[qrcode]]></ScanType>
    <ScanResult><![CDATA[2]]></ScanResult>
    </ScanCodeInfo>
</xml>

Parameter Description

Parameter Description
ToUserName Developer's WeChat ID
FromUserName Sender's WeChat ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Event
Event scancode_waitmsg
EventKey Event key value, set by developer during menu creation
ScanCodeInfo Content scanned
ScanType Scanning type: qrcode (in normal cases)
ScanResult Scanning result: string corresponding to the QR code

pic_sysphoto: Popping up System Camera window Event

An example of pushing an XML packet is as follows:

<xml>
    <ToUserName><![CDATA[gh_e136c6e50636]]></ToUserName>
    <FromUserName><![CDATA[oMgHVjngRipVsoxg6TuX3vz6glDg]]></FromUserName>
    <CreateTime>1408090651</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[pic_sysphoto]]></Event>
    <EventKey><![CDATA[6]]></EventKey>
    <SendPicsInfo><Count>1</Count>
    <PicList>
        <item>
            <PicMd5Sum><![CDATA[1b5f7c23b5bf75682a53e7b6d163e185]]></PicMd5Sum>
        </item>
    </PicList>
    </SendPicsInfo>
</xml>

Parameter Description

Parameter Description
ToUserName Developer's WeChat ID
FromUserName Sender's WeChat ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Event
Event pic_sysphoto
EventKey Event key value, set by developer during menu creation
SendPicsInfo Picture content sent
Count Number of pictures sent
PicList Picture list
PicMd5Sum Picture' MD5 value; used to verify pictures received if required

pic_photo_or_album: Popping up System Images or Camera window Event

An example of pushing an XML packet is as follows:

<xml>
    <ToUserName><![CDATA[gh_e136c6e50636]]></ToUserName>
    <FromUserName><![CDATA[oMgHVjngRipVsoxg6TuX3vz6glDg]]></FromUserName>
    <CreateTime>1408090816</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[pic_photo_or_album]]></Event>
    <EventKey><![CDATA[6]]></EventKey>
    <SendPicsInfo><Count>1</Count>
    <PicList>
        <item>
            <PicMd5Sum><![CDATA[5a75aaca956d97be686719218f275c6b]]></PicMd5Sum>
        </item>
    </PicList>
    </SendPicsInfo>
</xml>

Parameter Description

Parameter Description
ToUserName Developer's WeChat ID
FromUserName Sender's WeChat ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Event
Event pic_photo_or_album
EventKey Event key value, set by developer during menu creation
SendPicsInfo Picture content sent
Count Number of pictures sent
PicList Picture list
PicMd5Sum Picture' MD5 value; used to verify pictures received if required

pic_weixin: Popping up WeChat My Posts window Event

An example of pushing an XML packet is as follows:

<xml>
    <ToUserName><![CDATA[gh_e136c6e50636]]></ToUserName>
    <FromUserName><![CDATA[oMgHVjngRipVsoxg6TuX3vz6glDg]]></FromUserName>
    <CreateTime>1408090816</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[pic_weixin]]></Event>
    <EventKey><![CDATA[6]]></EventKey>
    <SendPicsInfo><Count>1</Count>
    <PicList>
        <item>
            <PicMd5Sum><![CDATA[5a75aaca956d97be686719218f275c6b]]></PicMd5Sum>
        </item>
    </PicList>
    </SendPicsInfo>
</xml>

Parameter Description

Parameter Description
ToUserName Developer's WeChat ID
FromUserName Sender's WeChat ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Event
Event pic_weixin
EventKey Event key value, set by developer during menu creation
SendPicsInfo Picture content sent
Count Number of pictures sent
PicList Picture list
PicMd5Sum Picture' MD5 value; used to verify pictures received if required

location_select: Popping up Location window Event

An example of pushing an XML packet is as follows:

<xml>
    <ToUserName><![CDATA[gh_e136c6e50636]]></ToUserName>
    <FromUserName><![CDATA[oMgHVjngRipVsoxg6TuX3vz6glDg]]></FromUserName>
    <CreateTime>1408091189</CreateTime>
    <MsgType><![CDATA[event]]></MsgType>
    <Event><![CDATA[location_select]]></Event>
    <EventKey><![CDATA[6]]></EventKey>
    <SendLocationInfo>
        <Location_X><![CDATA[23]]></Location_X>
        <Location_Y><![CDATA[113]]></Location_Y>
        <Scale><![CDATA[15]]></Scale>
        <Label><![CDATA[ 广州市海珠区客村艺苑路 106号]]></Label>
        <Poiname><![CDATA[]]></Poiname>
    </SendLocationInfo>
</xml>

Parameter Description

Parameter Description
ToUserName Developer's WeChat ID
FromUserName Sender's WeChat ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Event
Event location_select
EventKey Event key value, set by developer during menu creation
SendLocationInfo Location information sent
Location_X X Coordinate information
Location_Y Y Coordinate information
Scale Precision. The higher the precision, the higher the scale value
Label Location information, in the format of string
Poiname Name of the Moments POI. This field may be null.
Developer Guide
Custom-defined Menu
WeChat JS-SDK