订阅服务手册

跳转到: 导航, 搜索

服务简介

微博平台订阅服务提高了应用获取微博数据的效率。根据应用指定的订阅条件,如:关键词、用户、域名等,平台主动将新产生的数据实时推送给应用,应用不需要轮询请求接口。


订阅服务优点如下:

1、将新数据实时推送给应用;

2、节省网络开销;

3、提供数据量更多更全;

4、提高应用访问接口的效率;


订阅条件

订阅用户:

开发者可最多指定10000个用户。当订阅微博时,微博为指定用户发出的,则推送;当订阅评论时,评论对应的微博为指定用户产生的评论则推送;若不指定,则无此限制。


订阅关键词:

开发者可最多指定400个关键词。当订阅微博时,微博中含有指定关键词的,则推送;当订阅评论时,评论对应的微博含有此关键词的评论则推送;若不指定,则无此限制。


订阅域名:

开发者可最多指定20个域名。当订阅微博时,微博中包含短链所对应原始链接为指定域名下的,则推送;当订阅评论时,评论对应的微博内包含短链所对应原始链接为指定域名的评论则推送;若不指定,则无此限制。


订阅应用:

开发者可指定只推送生成订阅的应用产生的数据,若不指定则推送所有应用的数据。


订阅媒体类型:

当订阅微博时,才可以指定该条件。开发者可指定原创、转发、视频、音乐、或图片类型。则推送指定类型的微博;若不指定,则无此限制;当订阅评论时,无此筛选条件。


订阅数据类型:

开发者可指定推送微博、或评论数据;若不指定,则默认推送微博。


订阅百分比:

开发者可指定满足以上订阅条件的数据的百分比,若不指定,则推送满足条件的1%数据。


订阅时间范围:

开发者可指定推送开始时间和结束时间。在指定开始时间推送服务准备就绪,结束时间终止推送。若不指定,则开始时间默认等于订阅生成时间,一直推送。在推送服务准备就绪时,开发者可以调用接口进行连接,从而接收数据。


使用步骤

订阅服务使用步骤如下:

subscription.jpg


① 生成订阅:

开发者线下填写订阅服务申请单,填写订阅条件等信息,平台人员根据申请单信息,生成订阅。每个应用可以有多个订阅。


② 设置订阅的关键词、用户:

订阅服务申请单中“订阅关键词”、“订阅用户”选择否时,忽略此步骤。选择是时,则需保证关键词订阅列表和用户订阅列表一定不为空。订阅关键词、用户(若已经订阅了关键词、用户,则可忽略此步骤),请求接口:datapush/edit


The IP address to call the API must be one of the IP list provided when created the subscription. Otherwise, the error response ‘Ip is limited’ will be returned. If just parameter ‘subid’ is passed, the subscription info included the keywords and users list will be returned.


The length of each keyword can’t exceed 12 Chinese characters. The number of keywords parameter ‘add_keywords’ specified can’t exceed 20 per request. And the number of users parameter ‘add_users’ specified can’t exceed 50 per request. The total number of keywords subscribed can’t exceed 400 for each subscription. The total number of users subscribed can’t exceed 10000 for each subscription. The keywords and users can’t be subscribed repeatedly. Weibo Platform may protect some keywords and users when needed. Protected keywords and users can’t be subscribed. If a keyword is protected, the keywords that contain the protected keyword can’t be subscribed. The keywords and the datas filtered are not case-sensitive and don’t distinguish between Simplified and Traditional Chinese.


③ Pushing server is ready:

If developers did not provide the start time of the pushing, the start time is equal the time the subscription was created. Pushing server will be ready when arrives at the start time.


④ Application connects and pushing starts:

Only when the pushing server is ready can applications connect the pushing APIs, then pushing starts. Applications will receive the error information if the pushing server is not ready.


The pushing APIs are as follows:

● Subscribing for statuses, connect the API:datapush/status

● Subscribing for comments, connect the API:datapush/comment


⑤ Application receives datas:

Statuses or comments will be delivered to the application after connecting the pushing APIs successfully. The statuses or comments are JSON UTF-8 encoded datas. Every whole message is separated by \r\n and is less than 4096 bytes. Therefore, to make sure you get whole message, break out each message on \r\n boundaries.


See the responses for details.


⑥ Pushing ends:

If the end time is not specified, the pushing has no end. The pushing will be terminated when arrives at the end time. The subscription can’t be restarted.