During the interaction between the WeChat user and Service Account user, some of the user's actions cause the WeChat server to notify the developer of the server address set at the developer center in the form of an event push, allowing the developer to access the information.Some of these event pushes allow the developer to reply to the user after they occur, and some do not, as follows:

catalog

1 Attention / Cancel Attention to an Event

2 Scan QR code events with parameters

3 Report a geolocation incident

4 Custom Menu Events

5 Event Push When Clicking Menu to pull a message

6 Event Push When Clicking Menu to Jump Links

# Attention / Cancel attention to an event

When users follow and unfollow Service Account, WeChat will push this event to the developer's URL.It is convenient for developers to send welcome messages to users or to unbundle accounts. In order to protect the privacy of user data, developers need to delete all the information of the user when they receive the unattended event.

WeChat If the server does not receive a response within five seconds, it disconnects the connection and reinitiates the request for a total of three retries.

For retry message reloading, FromUserName + CreateTime is recommended.

If the server cannot guarantee that it will process and respond within five seconds, it can reply directly to the empty string, WeChat the server will not do anything about it and will not initiate a retry.

Push XML digital packet example:

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

Parameter explaination:

parameter describe
ToUserName Developer No. WeChat
FromUserName Sender account (an OpenID)
CreateTime Message Creation Time (integer)
MsgType Message type, event
Event Event type, subscribe, unsubscribe

Deploy this interface using a web debugging tool

# Scan QR code events with parameters

When a user scans a QR code with a scene value, the following two events may be pushed:

  1. If the user has not paid attention to Service Account, the user can pay attention to the service number, and WeChat will push the attention event with the scene value to the developer.
  2. If the user is already following Service Account, WeChat pushes the scene value scan event to the developer.

1. When the user is not following, post-follow event push

Push XML digital packet example:

<xml>
  <ToUserName><![CDATA[toUser]]></ToUserName>
  <FromUserName><![CDATA[FromUser]]></FromUserName>
  <CreateTime>123456789</CreateTime>
  <MsgType><![CDATA[event]]></MsgType>
  <Event><![CDATA[subscribe]]></Event>
  <EventKey><![CDATA[qrscene_123123]]></EventKey>
  <Ticket><![CDATA[TICKET]]></Ticket>
</xml>

Parameter explaination:

parameter describe
ToUserName Developer No. WeChat
FromUserName Sender account (an OpenID)
CreateTime Message Creation Time (integer)
MsgType Message type, event
Event Event type, subscribe
EventKey The event KEY value, prefixed by qrscene_, followed by the scene value ID of the binary code
Ticket Two dimensional code ticket, can be used in exchange for two dimensional code picture

2. Push events when users are already concerned

Push XML digital packet example:

<xml>
  <ToUserName><![CDATA[toUser]]></ToUserName>
  <FromUserName><![CDATA[FromUser]]></FromUserName>
  <CreateTime>123456789</CreateTime>
  <MsgType><![CDATA[event]]></MsgType>
  <Event><![CDATA[SCAN]]></Event>
  <EventKey><![CDATA[SCENE_VALUE]]></EventKey>
  <Ticket><![CDATA[TICKET]]></Ticket>
</xml> 

Parameter explaination:

parameter describe
ToUserName Developer No. WeChat
FromUserName Sender account (an OpenID)
CreateTime Message Creation Time (integer)
MsgType Message type, event
Event Event type, SCAN
EventKey Event KEY value, the scene value ID of the two-dimensional code
Ticket Two dimensional code ticket, can be used in exchange for two dimensional code picture

Deploy this interface using a web debugging tool

# Report a geolocation incident

After the user agrees to report the geolocation, each time the user enters a Service Account session, the geolocation is reported either at the time of entry or every 5 seconds after entering the session. The service number can modify the above setting in a public platform website.When a geolocation is reported, WeChat pushes the reported geolocation event to the developer's URL.

Push XML digital packet example:

<xml>
  <ToUserName><![CDATA[toUser]]></ToUserName>
  <FromUserName><![CDATA[fromUser]]></FromUserName>
  <CreateTime>123456789</CreateTime>
  <MsgType><![CDATA[event]]></MsgType>
  <Event><![CDATA[LOCATION]]></Event>
  <Latitude>23.137466</Latitude>
  <Longitude>113.352425</Longitude>
  <Precision>119.385040</Precision>
</xml>

Parameter explaination:

parameter describe
ToUserName Developer No. WeChat
FromUserName Sender account (an OpenID)
CreateTime Message Creation Time (integer)
MsgType Message type, event
Event Event type, LOCATION
Latitude Geographic location latitude
Longitude Geolocation Longitude
Precision Geolocation accuracy

Deploy this interface using a web debugging tool

# Custom Menu Events

When the user clicks on the custom menu, WeChat will push the click event to the developer. Please note that clicking on the menu will pop up a submenu and will not generate a report.

Event push when you click on the menu to pull a message

Push XML digital packet example:

<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 explaination:

parameter describe
ToUserName Developer No. WeChat
FromUserName Sender account (an OpenID)
CreateTime Message Creation Time (integer)
MsgType Message type, event
Event Event type, CLICK
EventKey Event KEY value, corresponding to the KEY value in the custom menu interface

Event push when you click on a menu link to a link

Push XML digital packet example:

<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 explaination:

parameter describe
ToUserName Developer No. WeChat
FromUserName Sender account (an OpenID)
CreateTime Message Creation Time (integer)
MsgType Message type, event
Event Event Type, VIEW
EventKey Event KEY value, set the jump URL

Deploy this interface using a web debugging tool