Statuses/followers
(→返回结果) |
|||
(未显示2个用户的4个中间版本) | |||
第1行: | 第1行: | ||
− | + | {{api_desc2| | |
− | + | uri=statuses/followers| | |
− | + | desc=获取用户粉丝列表及每个粉丝的最新一条微博,返回结果按粉丝的关注时间倒序排列,最新关注的粉丝排在最前面。每次返回20个,通过cursor参数来取得多于20的粉丝。注意目前接口最多只返回5000个粉丝。| | |
− | = | + | format=XML/JSON| |
− | + | httpMethod=GET| | |
− | + | needAuth=false| | |
− | = | + | rateLimit=true| |
− | + | params={{api_args|:id|false|int64/string|用户ID(int64)或者昵称(string)。该参数为一个REST风格参数。调用示例见注意事项}} | |
− | + | {{api_args|user_id|false|int64|用户ID,主要是用来区分用户ID跟微博昵称。当微博昵称为数字导致和用户ID产生歧义,特别是当微博昵称和用户ID一样的时候,建议使用该参数}} | |
− | + | {{api_args|screen_name|false|string|微博昵称,主要是用来区分用户UID跟微博昵称,当二者一样而产生歧义的时候,建议使用该参数}} | |
− | GET | + | {{api_args|cursor|false|int|用于分页请求,请求第1页cursor传-1,在返回的结果中会得到next_cursor字段,表示下一页的cursor。next_cursor为0表示已经到记录末尾。}} |
− | + | {{api_args|count|false|int,默认20,最大200|每页返回的最大记录数,最大不能超过200,默认为20。}} | |
− | + | {{api_args_colspan|1=<font style="color:#ee3333">:id, user_id, screen_name 可以任选一个参数,在3个都不提供的情况下,系统返回当前登录用户的粉丝列表</font>}}| | |
− | + | getParam=&user_id=11051| | |
− | + | postParam=| | |
− | = | + | result= |
− | true | + | ===XML示例=== |
− | + | ||
− | = | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | === | + | |
− | + | ||
<pre> | <pre> | ||
− | + | <?xml version="1.0" encoding="UTF-8"?> | |
− | + | <users> | |
− | + | ||
<user> | <user> | ||
− | + | <id>11088</id> | |
− | + | <screen_name>Garfield_init</screen_name> | |
− | + | <name>Garfield_init</name> | |
− | + | <province>44</province> | |
− | + | <city>1</city> | |
− | + | <location>广东 广州</location> | |
− | + | <description>编号11088...</description> | |
− | + | <url>http://blog.sina.com.cn/gsj11088</url> | |
− | + | <profile_image_url>http://tp1.sinaimg.cn/11088/50/1291346587/1</profile_image_url> | |
− | + | <domain>uc11088</domain> | |
− | + | <gender>m</gender> | |
− | + | <followers_count>131</followers_count> | |
− | + | <friends_count>97</friends_count> | |
− | + | <statuses_count>875</statuses_count> | |
− | + | <favourites_count>16</favourites_count> | |
− | + | <created_at>Fri Sep 04 00:00:00 +0800 2009</created_at> | |
− | + | <following>false</following> | |
− | + | <verified>false</verified> | |
− | + | <allow_all_act_msg>false</allow_all_act_msg> | |
− | + | <geo_enabled>true</geo_enabled> | |
− | + | <status> | |
− | + | <created_at>Fri Dec 03 11:43:14 +0800 2010</created_at> | |
− | + | <id>4049048423</id> | |
− | + | <text>#818招行卡优商#原来在这里...http://sinaurl.cn/hbyXm3</text> | |
− | + | <source> | |
− | + | <a href="http://all.vic.sina.com.cn/cmb/">招行信用卡8周年</a> | |
− | + | </source> | |
− | + | <favorited>false</favorited> | |
− | + | <truncated>false</truncated> | |
− | + | <geo/> | |
− | + | <in_reply_to_status_id/> | |
− | + | <in_reply_to_user_id/> | |
− | + | <in_reply_to_screen_name/> | |
+ | </status> | ||
</user> | </user> | ||
− | + | ... | |
− | <next_cursor> | + | <next_cursor>1</next_cursor> |
<previous_cursor>0</previous_cursor> | <previous_cursor>0</previous_cursor> | ||
− | + | </users> | |
− | + | ||
</pre> | </pre> | ||
− | JSON示例 | + | ===JSON示例=== |
<pre> | <pre> | ||
− | + | { | |
− | + | "users" : | |
− | + | [ | |
− | + | { | |
− | + | "name" : "Garfield_init", | |
− | + | "domain" : "uc11088", | |
− | + | "geo_enabled" : true, | |
− | + | "followers_count" : 131, | |
− | + | "statuses_count" : 875, | |
− | + | "favourites_count" : 16, | |
− | + | "city" : "1", | |
− | + | "description" : "编号11088...", | |
− | + | "verified" : false, | |
− | + | "status" : | |
− | + | { | |
− | + | "created_at" : "Fri Dec 03 11:43:14 +0800 2010", | |
− | + | "text" : "#818招行卡优商#原来在这里...http://sinaurl.cn/hbyXm3", | |
− | + | "truncated" : false, | |
− | + | "in_reply_to_status_id" : "", | |
− | + | "in_reply_to_screen_name" : "", | |
− | + | "geo" : null, | |
− | + | "favorited" : false, | |
− | + | "in_reply_to_user_id" : "", | |
− | + | "id" : 4049048423, | |
− | + | "source" : "<a href=\"http://all.vic.sina.com.cn/cmb/\" rel=\"nofollow\">招行信用卡8周年</a>" | |
− | + | }, | |
− | + | "id" : 11088, | |
− | + | "gender" : "m", | |
− | </pre> | + | "friends_count" : 97, |
− | + | "screen_name" : "Garfield_init", | |
− | + | "allow_all_act_msg" : false, | |
− | + | "following" : false, | |
− | + | "url" : "http://blog.sina.com.cn/gsj11088", | |
− | + | "profile_image_url" : "http://tp1.sinaimg.cn/11088/50/1291346587/1", | |
− | * | + | "created_at" : "Fri Sep 04 00:00:00 +0800 2009", |
− | + | "province" : "44", | |
− | + | "location" : "广东 广州" | |
− | + | }, | |
− | + | ... | |
− | + | ], | |
− | ====Java示例 | + | "next_cursor" : 1, |
+ | "previous_cursor" : 0 | ||
+ | } | ||
+ | </pre>| | ||
+ | useAge= | ||
+ | * 注意,该接口不要求登录。如果没有登录,则每次最多只能返回20个粉丝。如果登录后则可以返回更多粉丝。 | ||
+ | * :id为REST风格的参数,使用该参数的URL为:<br/> http://api.t.sina.com.cn/statuses/followers/:id.format <br/> 使用示例如下:<br/> http://api.t.sina.com.cn/statuses/followers/11051.xml?source=appkey<br/>http://api.t.sina.com.cn/statuses/followers/timyang.json?source=appkey | ||
+ | * 如果没有提供cursor参数,将只返回最前面的20个粉丝。| | ||
+ | otherInfo= | ||
+ | ===Java示例=== | ||
请从 [[SDK | 微博SDK开发包下载]] 下载Java SDK<br> | 请从 [[SDK | 微博SDK开发包下载]] 下载Java SDK<br> | ||
代码示例如下: | 代码示例如下: | ||
第165行: | 第152行: | ||
} | } | ||
} | } | ||
− | + | ===PHP示例=== | |
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br> | 请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br> | ||
代码示例如下: | 代码示例如下: | ||
第191行: | 第178行: | ||
} | } | ||
</pre> | </pre> | ||
+ | }} |
2012年9月24日 (一) 11:39的最后版本
目录 |
statuses/followers
获取用户粉丝列表及每个粉丝的最新一条微博,返回结果按粉丝的关注时间倒序排列,最新关注的粉丝排在最前面。每次返回20个,通过cursor参数来取得多于20的粉丝。注意目前接口最多只返回5000个粉丝。
URL
http://api.t.sina.com.cn/statuses/followers.(json%7Cxml)
支持格式
XML/JSON
HTTP请求方式
GET
是否需要登录
false
关于授权机制,参见授权机制声明
请求数限制
true
关于请求数限制,参见接口访问权限说明
请求参数
必选 | 类型及范围 | 说明 | |
---|---|---|---|
source | true | string | 申请应用时分配的AppKey,调用接口时候代表应用的唯一身份。(采用OAuth授权方式不需要此参数) |
:id | false | int64/string | 用户ID(int64)或者昵称(string)。该参数为一个REST风格参数。调用示例见注意事项 |
user_id | false | int64 | 用户ID,主要是用来区分用户ID跟微博昵称。当微博昵称为数字导致和用户ID产生歧义,特别是当微博昵称和用户ID一样的时候,建议使用该参数 |
screen_name | false | string | 微博昵称,主要是用来区分用户UID跟微博昵称,当二者一样而产生歧义的时候,建议使用该参数 |
cursor | false | int | 用于分页请求,请求第1页cursor传-1,在返回的结果中会得到next_cursor字段,表示下一页的cursor。next_cursor为0表示已经到记录末尾。 |
count | false | int,默认20,最大200 | 每页返回的最大记录数,最大不能超过200,默认为20。 |
:id, user_id, screen_name 可以任选一个参数,在3个都不提供的情况下,系统返回当前登录用户的粉丝列表 |
注意事项
- 注意,该接口不要求登录。如果没有登录,则每次最多只能返回20个粉丝。如果登录后则可以返回更多粉丝。
- :id为REST风格的参数,使用该参数的URL为:
http://api.t.sina.com.cn/statuses/followers/:id.format
使用示例如下:
http://api.t.sina.com.cn/statuses/followers/11051.xml?source=appkey
http://api.t.sina.com.cn/statuses/followers/timyang.json?source=appkey - 如果没有提供cursor参数,将只返回最前面的20个粉丝。
返回结果
XML示例
<?xml version="1.0" encoding="UTF-8"?> <users> <user> <id>11088</id> <screen_name>Garfield_init</screen_name> <name>Garfield_init</name> <province>44</province> <city>1</city> <location>广东 广州</location> <description>编号11088...</description> <url>http://blog.sina.com.cn/gsj11088</url> <profile_image_url>http://tp1.sinaimg.cn/11088/50/1291346587/1</profile_image_url> <domain>uc11088</domain> <gender>m</gender> <followers_count>131</followers_count> <friends_count>97</friends_count> <statuses_count>875</statuses_count> <favourites_count>16</favourites_count> <created_at>Fri Sep 04 00:00:00 +0800 2009</created_at> <following>false</following> <verified>false</verified> <allow_all_act_msg>false</allow_all_act_msg> <geo_enabled>true</geo_enabled> <status> <created_at>Fri Dec 03 11:43:14 +0800 2010</created_at> <id>4049048423</id> <text>#818招行卡优商#原来在这里...http://sinaurl.cn/hbyXm3</text> <source> <a href="http://all.vic.sina.com.cn/cmb/">招行信用卡8周年</a> </source> <favorited>false</favorited> <truncated>false</truncated> <geo/> <in_reply_to_status_id/> <in_reply_to_user_id/> <in_reply_to_screen_name/> </status> </user> ... <next_cursor>1</next_cursor> <previous_cursor>0</previous_cursor> </users>
JSON示例
{ "users" : [ { "name" : "Garfield_init", "domain" : "uc11088", "geo_enabled" : true, "followers_count" : 131, "statuses_count" : 875, "favourites_count" : 16, "city" : "1", "description" : "编号11088...", "verified" : false, "status" : { "created_at" : "Fri Dec 03 11:43:14 +0800 2010", "text" : "#818招行卡优商#原来在这里...http://sinaurl.cn/hbyXm3", "truncated" : false, "in_reply_to_status_id" : "", "in_reply_to_screen_name" : "", "geo" : null, "favorited" : false, "in_reply_to_user_id" : "", "id" : 4049048423, "source" : "<a href=\"http://all.vic.sina.com.cn/cmb/\" rel=\"nofollow\">招行信用卡8周年</a>" }, "id" : 11088, "gender" : "m", "friends_count" : 97, "screen_name" : "Garfield_init", "allow_all_act_msg" : false, "following" : false, "url" : "http://blog.sina.com.cn/gsj11088", "profile_image_url" : "http://tp1.sinaimg.cn/11088/50/1291346587/1", "created_at" : "Fri Sep 04 00:00:00 +0800 2009", "province" : "44", "location" : "广东 广州" }, ... ], "next_cursor" : 1, "previous_cursor" : 0 }
其他
Java示例
请从 微博SDK开发包下载 下载Java SDK
代码示例如下:
package weibo4j.examples; import java.util.List; import weibo4j.User; import weibo4j.Weibo; import weibo4j.WeiboException; public class GetFollowers { /** * 返回用户关注对象列表,并返回最新微博文章。 * @param args */ public static void main(String[] args) { System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY); System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET); try { Weibo weibo = getWeibo(false,args); List<User> list = weibo.getFollowersStatuses(); for(User user : list) { System.out.println(user.toString()); } } catch (WeiboException e) { e.printStackTrace(); } } private static Weibo getWeibo(boolean isOauth,String[] args) { Weibo weibo = new Weibo(); if(isOauth) {//oauth验证方式 args[0]:访问的token;args[1]:访问的密匙 weibo.setToken(args[0], args[1]); }else {//用户登录方式 weibo.setUserId(args[0]);//用户名/ID weibo.setPassword(args[1]);//密码 } return weibo; } }
PHP示例
请从 微博SDK开发包下载 处下载PHP SDK(支持OAuth验证之版本)
代码示例如下:
//Statuses/followers //返回用户关注对象列表,并返回最新微博文章。 $c = new WeiboClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret'] ); //用户ID $u_id = "u_id"; $msg = $c->followers(false, false, $u_id); if ($msg === false || $msg === null){ echo "Error occured"; return false; } if (isset($msg['error_code']) && isset($msg['error'])){ echo ('Error_code: '.$msg['error_code'].'; Error: '.$msg['error'] ); return false; } foreach($msg as $follower){ echo($follower['id'].' : '.$follower['name'].' '.$follower['created_at'].' ;'); }
文档更新时间: 2012-09-24