Subscription Service Manual



Service Introduction

Weibo platform subscription service improves the efficiency of applications in obtaining Weibo data. According to the subscription conditions specified by the application, such as keywords, users, domain names, etc., the platform actively pushes the newly generated data to the application in real time, and the application does not need to poll the request interface.


The advantages of the subscription service are as follows:

1. Push new data to the application in real time;

2. Save network overhead;

3. Provide more and more complete data;

4. Improve the efficiency of application access interface;


Subscription conditions

Subscribers:

Developers can specify up to 10,000 users. When subscribing to Weibo, if the Weibo is posted by the specified user, it will be pushed; when subscribing to comments, the comments posted by the specified user on Weibo (not comments posted by the specified user) will be pushed; if not specified, there is no such restriction.


Subscription keywords:

Developers can specify up to 20,000 keywords. When subscribing to Weibo, if the Weibo contains the specified keyword, it will be pushed; when subscribing to comments, if the Weibo corresponding to the comment contains this keyword, or the comment itself contains this keyword, it will be pushed; if not specified, there will be no such limit.

Note: When the forwarded Weibo content does not contain this keyword, but the original Weibo contains it, in this case it will not be pushed


Subscription domain name:

Developers can specify up to 20 domain names. When subscribing to Weibo, if the original link corresponding to the short link in the Weibo is under the specified domain name, it will be pushed; when subscribing to a comment, if the comment corresponding to the Weibo contains the original link corresponding to the short link and is under the specified domain name, it will be pushed; If not specified, there is no such restriction.


Subscription application:

Developers can specify to push only the data generated by the application that generates the subscription. If not specified, the data of all applications will be pushed.


Subscription media type:

This condition can only be specified when subscribing to Weibo. Developers can specify original, forwarded, video, music, or picture types. Then push the specified type of Weibo; if not specified, there is no such restriction; when subscribing to comments, there is no such filtering condition.


Subscription data type:

Developers can specify to push Weibo or comment data; if not specified, Weibo will be pushed by default.


Subscription percentage:

Developers can specify the percentage of data that meets the above subscription conditions. If not specified, 1% of the data that meets the conditions will be pushed.


Subscription time range:

Developers can specify the push start time and end time. The push service is ready at the specified start time and terminated at the end time. If not specified, the start time defaults to the subscription generation time and is pushed continuously. When the push service is ready, developers can call the interface to connect and receive data.

Steps to use

The steps to use the subscription service are as follows:

subscription.png


① Generate subscription:

Developers fill in the subscription service application form offline and fill in information such as subscription conditions. Platform personnel generate subscriptions based on the application form information. Each application can have multiple subscriptions. Developers who need to try out the subscription service should submit an application online (see the access guide for details) without filling out an application form.


② Set subscription keywords and users:

When "Subscription Keywords" and "Subscribe User" are selected as No in the subscription service application form, it will be ignored. this step. When you select Yes, you need to ensure that the keyword subscription list and user subscription list are not empty. Subscribe to keywords and users (if you have already subscribed to keywords and users, you can ignore this step), request interface: subscribe/update_subscribe


The IP requested for this interface must be the IP list specified during subscription An IP address in the system, otherwise an error message will be returned: Ip is limited. When only subid is passed, the subscription information of the subscription is returned, including the subscription keyword list and user list.


Each keyword is separated by a comma, and there is a logical "OR" relationship between the keywords separated by commas.

The length of each keyword cannot exceed 36 Chinese characters.

Each keyword supports "AND" and "NOT" logic internally. Logical "AND" is separated by "space": such as A B; logical "NOT" is separated by "space -": such as A - B. When there are double quotes on both sides of the keyword, it means that the content of the keyword absolutely matches and the logical operation is invalid, such as: "A B", which no longer represents logical A and B.

The total number of sub-keywords separated by logical operators within each keyword cannot exceed 1,000, and the number of logical operators for each subscription cannot exceed 500.

The keywords subscribed to each time the interface is called cannot exceed 20. The number of users subscribed to each call to the interface cannot exceed 50. The total number of keywords and users for each subscription cannot exceed 20,000, and repeated subscriptions are not allowed.

The Weibo platform will set certain keywords and users to a protected state, and protected keywords and users cannot be subscribed. After a keyword is protected, words containing this keyword cannot be subscribed. Subscribed keywords and data filtered by keywords are not case-sensitive, simplified or traditional.


③ Push service is ready:

If the developer specifies the push start time in the application form, the push service of the subscription will be ready at the specified start time ; If not specified, the push service will be ready after the subscription is generated.


④ Application connection and push start:

If the subscription has been generated but the push service is not ready, the push status in the developer subscription management background will display: Preparing; if the push service is ready, it will display: Ready. Only in the ready state can the application call the interface to connect and receive data. Otherwise, an error will be reported when calling the interface.


The calling interface is as follows:

● To subscribe to Weibo, the calling interface is: datapush/status

● To subscribe to comments, the calling interface is: datapush/comment


java call, see sample code.


⑤ The application receives data:

After the connection is successful, the interface will push Weibo or comment data to the developer's connection address. Each complete Weibo or comment data is returned in json format, UTF-8 encoding is used by default, and is separated by \r\n. The maximum length of each data message is 4096 bytes.


Return data see: example.


⑥ Push termination:

If the developer does not specify the push end time, it will continue to push; if the end time is specified, it will be pushed at the specified push end time. Terminate push. This is equivalent to the expiration of this subscription and will not be restarted.


Instructions for use

The application receives data through the HTTP long connection request interface /datapush/status or /datapush/comment. The parameter subid (subscription ID) needs to be passed in to tell the platform which subscription data to push. If the request is correct, the corresponding data result will be returned. If the request is abnormal, the corresponding error message will be returned.


In order to relieve the pressure on the server, the platform push data will be disconnected every ten minutes. The application needs to be compatible, re-HTTP long connection request interface, and can bring the id value of the last disconnection. Pass it in as the value of the parameter since_id, such as: /datapush/status?subid=xxx&since_id=XXX. The application can continuously obtain data from the disconnected point. Therefore, the application needs to retain the id when the service is disconnected as the parameter value of the next request.


Because the data pushed by the subscription service is real-time, the platform only retains five minutes of data. If it is disconnected for more than five minutes, the parameter since_id is no longer supported. If since_id is passed in, an error message will be returned. :Illegal param since_id (since_id is illegal and exceeds the time limit). If since_id is not passed, the platform will filter the data that meets the conditions among the first 50,000 data at the current time point and push it to the user.


When an application encounters illegal operations or other reasons, the platform will suspend the data push function of the subscription, that is, it will no longer push data. Until the problem is resolved, the platform can restart the push function. The application requires HTTP long connection to re-request the interface.


In addition, the IP of the application request interface must be an IP address in the IP list specified when subscribing, otherwise an error message will be returned: Ip is limited (ip is limited).


Status Description

In the Developer Management Center, you can see the various display statuses of the service, as shown in the red box below:
subscription_start.png

There are five service statuses: preparing, ready, enabled, suspended, and terminated.


1) Preparing:

The subscription has been generated but has not reached the push start time specified by the developer, and is in the preparing state (the developer cannot connection to receive data). If the developer does not specify the push start time, after the subscription is generated, there will be no preparing state and it will directly enter the ready state.


2) Ready:

The subscription is generated and the push start time has arrived, but the developer is not connected to receive data, so it is in a ready state. Or when the subscription is generated, the developer does not specify the push start time, and the developer is not connected to receive data, the service is also in a ready state.


3) Opened:

In the ready state, the developer connects to receive data and the service enters the open state.


4) Suspended:

When the application has illegal operations or due to other reasons, the platform suspends the push function of the subscription, and the service will be converted to suspended. Paused state.


5) Terminated:

If the developer does not specify the push end time, the push will continue; if the end time is specified, the push will end at the specified Time to terminate push. This is equivalent to the expiration of this subscription and will not be restarted. At this time, the service is in the terminated state;


##Language: 中文 | English