订阅服务手册

跳转到: 导航, 搜索
第74行: 第74行:
  
  
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.
+
请求该接口的IP一定是订阅时指定的IP列表中的某个IP地址,否则会返回错误提示:Ip is limited(ip受限)。当只传subid时,返回该订阅的订阅信息,包括订阅的关键词列表、用户列表。
  
  
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.
+
每个关键词长度不能超出12个汉字。每次订阅的关键词不能超过20个。每次订阅的用户不能超过50个。每个订阅的关键词订阅总数不能超过400个,且不能重复订阅关键词。每个订阅的用户订阅总数不能超过10000个,且不能重复订阅用户。微博平台对某些关键词和用户会设置成保护状态,被保护的关键词和用户不能被订阅。一个关键词被保护后,包含此关键词的词都不能被订阅。订阅的关键词及按关键词过滤后的数据不区分大小写、简繁体。
  
  
<font size="2" style="font-weight:bold">③ Pushing server is ready:</font>
+
<font size="2" style="font-weight:bold">③ 推送服务就绪:</font>
  
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.
+
开发者若在申请单中指定了推送开始时间,则在指定开始时间该订阅的推送服务就绪;若没有指定,则订阅生成后推送服务就已经就绪。
  
  
<font size="2" style="font-weight:bold">④ Application connects and pushing starts:</font>
+
<font size="2" style="font-weight:bold">④ 应用连接、推送开始:</font>
  
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:[[C/2/datapush/status|datapush/status]]
+
订阅微博,调用接口:[[C/2/datapush/status|datapush/status]]
  
Subscribing for comments, connect the API:[[C/2/datapush/comment|datapush/comment]]
+
订阅评论,调用接口:[[C/2/datapush/comment|datapush/comment]]
  
  
<font size="2" style="font-weight:bold">⑤ Application receives datas:</font>
+
<font size="2" style="font-weight:bold">⑤ 应用接收数据:</font>
  
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.
+
连接成功后,接口将向开发者的连接地址推送微博、或评论数据。每条完整的微博或评论数据以json形式返回,默认采用UTF-8编码,且以\r\n分隔。每条数据信息最大长度为4096字节。
  
  
See the [[responses]] for details.
+
返回数据见:[[示例]]
  
  
<font size="2" style="font-weight:bold">⑥ Pushing ends:</font>
+
<font size="2" style="font-weight:bold">⑥ 推送终止:</font>
  
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.
+
若开发者未指定推送结束时间,则一直推送;若指定结束时间,则在指定的推送结束时间终止推送。相当于此订阅过期,不会再被重启使用。

2013年10月14日 (一) 12:10的版本

服务简介

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


订阅服务优点如下:

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

2、节省网络开销;

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

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


订阅条件

订阅用户:

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


订阅关键词:

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


订阅域名:

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


订阅应用:

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


订阅媒体类型:

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


订阅数据类型:

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


订阅百分比:

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


订阅时间范围:

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


使用步骤

订阅服务使用步骤如下:

subscription.jpg


① 生成订阅:

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


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

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


请求该接口的IP一定是订阅时指定的IP列表中的某个IP地址,否则会返回错误提示:Ip is limited(ip受限)。当只传subid时,返回该订阅的订阅信息,包括订阅的关键词列表、用户列表。


每个关键词长度不能超出12个汉字。每次订阅的关键词不能超过20个。每次订阅的用户不能超过50个。每个订阅的关键词订阅总数不能超过400个,且不能重复订阅关键词。每个订阅的用户订阅总数不能超过10000个,且不能重复订阅用户。微博平台对某些关键词和用户会设置成保护状态,被保护的关键词和用户不能被订阅。一个关键词被保护后,包含此关键词的词都不能被订阅。订阅的关键词及按关键词过滤后的数据不区分大小写、简繁体。


③ 推送服务就绪:

开发者若在申请单中指定了推送开始时间,则在指定开始时间该订阅的推送服务就绪;若没有指定,则订阅生成后推送服务就已经就绪。


④ 应用连接、推送开始:

若订阅已经生成,但推送服务未就绪,则开发者订阅管理后台的推送状态显示:准备中;若推送服务已经就绪,则显示:准备就绪。在准备就绪状态下,应用才可以调用接口进行连接,接收数据。否则,调用接口时报错。


调用接口如下:

● 订阅微博,调用接口:datapush/status

● 订阅评论,调用接口:datapush/comment


⑤ 应用接收数据:

连接成功后,接口将向开发者的连接地址推送微博、或评论数据。每条完整的微博或评论数据以json形式返回,默认采用UTF-8编码,且以\r\n分隔。每条数据信息最大长度为4096字节。


返回数据见:示例


⑥ 推送终止:

若开发者未指定推送结束时间,则一直推送;若指定结束时间,则在指定的推送结束时间终止推送。相当于此订阅过期,不会再被重启使用。