# [Mini Program live] Long-term subscription related interface

# A long-term subscription status synchronization interface

Event notifications will be triggered after users subscribe to the Mini Program live stream

# Long Term Subscription Status Synchronization Interface

# Message parameter

# Object

attribute type Introductions
ToUserName string The original ID of the Mini Program
FromUserName string Sender's openid
CreateTime number Message creation time (integer)
MsgType string fixed event
Event string fixed wxalive_follow_notify
room_id number Room number
user_openid string Subscriber's openid
time number Timestamp of subscription
live_status number Subscription or unsubscription live status, values: 101 (live), 102 (not started), 103 (finished)
action string Subscription behavior

action Legal value

value Introductions
add_follow Subscribe
of the_follow Unsubscribe

# Message Packet Sample

XML format

<xml>
  <ToUserName><![CDATA[toUser]]></ToUserName>
  <FromUserName><![CDATA[fromUser]]></FromUserName>
  <CreateTime>1546924844</CreateTime>
  <MsgType><![CDATA[event]]></MsgType>
  <Event><![CDATA[wxalive_follow_notify]]></Event>
  <FollowNotify>
    <room_id>1</room_id>
    <user_openid>![CDATA[xxx]]</user_openid>
    <time>1546924844</time>
    <live_status>101</live_status>
    <action>![CDATA[add_follow]]</action>
  </FollowNotify>
 </xml>

# Second, long-term subscription group interface

# 1. Get long-term subscribers

# Interface Dxplaination

Call this interface to get a list of long-term subscribers

# Call frequency

Call quota: 5000 times/One day.

# Request method

POST

# Requested URL:

https://api.weixin.qq.com/wxa/business/get_wxa_followersaccess_token=

# Sample request parameters: json

{    
    "limit": 200,
    "page_break":0 
}

# Request parameter meaning

parameter type Required Introductions
limit Number no Get the number of long-term subscribers limit, default 200, maximum 2000
page_break Number no Turn page mark, get the first page without, the second page to start with the previous page to return the results of the page_break

# Return Examples Correctly

{  
    "followers": [
        {
            "openid": "openid1",
            "subscribe_time": 1606270612,
            "room_status": 101,
            "room_id": 1
        },

        {
            "openid": "openid2",
            "subscribe_time": 1606270612,
            "room_status": 101,
            "room_id": 1
        }
    ],
    "page_break": 1606270612,
    "errcode": 0,
    "errmsg": "ok",
}

# Return Parameter Meaning

parameter Introductions
followers List of long-term subscribers
openid Long term subscribers OpenId
subscribe_time Subscription time for long-term subscribers
room_id Room where the user subscribes
room_status Room status when user subscribes
page_break Page Turn Tag, which is carried when getting the next page
Errcode Interface return code, 0 means success, non-0 means failure
errmsg Interface return prompt

# 2. Long term subscription group hair interface

# Interface Dxplaination

Group Live Room Start Event to Long Term Subscribers

# Call frequency

Call quota: 5000 times/One day.Group subscription number limit: 2000/second

# Request method

POST

# Requested URL:

https://api.weixin.qq.com/wxa/business/push_messageaccess_token=

# Example request parameter: json

{
    "room_id": 1,
    "user_openid":["openid1", "openid2"] 
}

# Request parameter meaning

parameter type Required Introductions
room_id Number yes Room ID of live start event
user_openid Array yes OpenId list of subscribers who receive this multicast initiation event

# Return Examples Correctly

{
    "message_id":"message_id",
    "errcode": 0,
    "errmsg": "ok",
}

# Return Parameter Meaning

parameter Introductions
message_id The identification ID of the group message, used to correspond to the message [long-term subscription group results callback]_id
Errcode Interface return code, 0 for success, non-0 for failure. If errcode = 0 only indicates that the trigger interface is successful, the final results of the group see [long-term subscription group results callback]
errmsg Interface return prompt

# 3. Long term subscription group results callback

# Callback explaination

Asynchronously Returns the End Result of Long Term Subscription

# Callback URL configuration

♪ mp.WeChat.qq . com ] - >[Mini Program] ->[Development] ->[Development Management] ->[Development settings] ->[Message Push]

# Message parameter

# Object

attribute type Introductions
ToUserName String The original ID of the Mini Program
FromUserName String OpenId of sender
CreateTime Number Message creation time (integer)
MsgType String fixed event
Event String fixed wxalive_push_message_notify
message_id String Identification ID of a group message
room_id Number Room number
total_count Number Group message user_Total number of openid
success_count Number Number of successful group messages
openid_error_count Number Number of openid errors
relation_error_count Number Number of errors due to users not following this Mini Program
user_recv_limit_count Number Number of errors caused by users receiving messages exceeding the limit
internal_error_count Number Number of other errors

# Message Packet Sample

XML format

<xml>
   <ToUserName><![CDATA[xxx]]></ToUserName>
   <FromUserName><![CDATA[xxx]]></FromUserName>
   <CreateTime>1606273828</CreateTime>
   <MsgType><![CDATA[event]]></MsgType>
   <Event><![CDATA[wxalive_push_message_notify]]></Event>
   <PushMessageApiNotify>
      <message_id><![CDATA[1622047360795164672]]></message_id>
      <room_id>xxx</room_id>
      <total_count>xxx</total_count>
      <success_count>xxx</success_count>
      <openid_error_count>xxx</openid_error_count>
      <relation_error_count>xxx</relation_error_count>
      <user_recv_limit_count>xxx</user_recv_limit_count>
      <internal_error_count>xxx</internal_error_count>
   </PushMessageApiNotify>
</xml>