Statuses/followers

跳转到: 导航, 搜索
(statuses/followers)
 
(未显示1个用户的3个中间版本)
第1行: 第1行:
== statuses/followers ==
+
{{api_desc2|
返回用户的粉丝列表,并返回粉丝的最新微博。按粉丝的关注时间倒序返回,每次返回100个,通过cursor参数来取得多于100的粉丝。注意目前接口最多只返回5000个粉丝。
+
uri=statuses/followers|
 
+
desc=获取用户粉丝列表及每个粉丝的最新一条微博,返回结果按粉丝的关注时间倒序排列,最新关注的粉丝排在最前面。每次返回20个,通过cursor参数来取得多于20的粉丝。注意目前接口最多只返回5000个粉丝。|
=== URL===
+
format=XML/JSON|
http://api.t.sina.com.cn/statuses/followers.format
+
httpMethod=GET|
+
needAuth=false|
=== 格式===
+
rateLimit=true|
xml, json
+
params={{api_args|:id|false|int64/string|用户ID(int64)或者昵称(string)。该参数为一个REST风格参数。调用示例见注意事项}}
+
{{api_args|user_id|false|int64|用户ID,主要是用来区分用户ID跟微博昵称。当微博昵称为数字导致和用户ID产生歧义,特别是当微博昵称和用户ID一样的时候,建议使用该参数}}
=== HTTP请求方式===
+
{{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>}}|
true
+
getParam=&user_id=11051|
 
+
postParam=|
=== 请求数限制===
+
result=
true
+
===XML示例===
 
+
=== 请求参数===
+
* id.  选填参数.  要获取粉丝的 UID或微博昵称 
+
o 示例: http://api.t.sina.com.cn/statuses/followers/12345.json or http://api.t.sina.com.cn/statuses/followers/bob.xml
+
* user_id. 选填参数.  要获取的UID
+
o 示例: http://api.t.sina.com.cn/statuses/followers.xml?user_id=1401881
+
* screen_name.  选填参数.  要获取的微博昵称
+
o 示例: http://api.t.sina.com.cn/statuses/followers.xml?screen_name=101010
+
* cursor. 选填参数. 单页只能包含100个粉丝列表,为了获取更多则cursor默认从-1开始,通过增加或减少cursor来获取更多的,如果没有下一页,则next_cursor返回0
+
粉丝列表
+
o 示例: http://api.t.sina.com.cn/statuses/followers/barackobama.xml?cursor=-1
+
o 示例: http://api.t.sina.com.cn/statuses/followers/barackobama.xml?cursor=1300794057949944903
+
* count.  可选参数.  每次返回的最大记录数(即页面大小),不大于200,默认返回20。
+
o 示例: http://api.t.sina.com.cn/statuses/followers/bob.xml?&count=200
+
 
+
=== 使用说明===
+
* 为了保护用户隐私,只有用户设置了公开或对粉丝设置了公开的数据才会返回。
+
* 如果没有提供cursor参数,将只返回最前面的100个关注列表
+
 
+
=== 返回结果 ===
+
====XML====
+
 
<pre>
 
<pre>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<users>
 
<users>
 
   <user>
 
   <user>
     <id>1644917462</id>
+
     <id>11088</id>
     <screen_name>大竹006</screen_name>
+
     <screen_name>Garfield_init</screen_name>
     <name>大竹006</name>
+
     <name>Garfield_init</name>
     <province>11</province>
+
     <province>44</province>
     <city>1000</city>
+
     <city>1</city>
     <location>北京</location>
+
     <location>广东 广州</location>
     <description/>
+
     <description>编号11088...</description>
     <url/>
+
     <url>http://blog.sina.com.cn/gsj11088</url>
     <profile_image_url>http://tp3.sinaimg.cn/1644917462/50/0</profile_image_url>
+
     <profile_image_url>http://tp1.sinaimg.cn/11088/50/1291346587/1</profile_image_url>
     <domain/>
+
     <domain>uc11088</domain>
 
     <gender>m</gender>
 
     <gender>m</gender>
     <followers_count>0</followers_count>
+
     <followers_count>131</followers_count>
     <friends_count>19</friends_count>
+
     <friends_count>97</friends_count>
     <statuses_count>0</statuses_count>
+
     <statuses_count>875</statuses_count>
     <favourites_count>0</favourites_count>
+
     <favourites_count>16</favourites_count>
     <created_at>Mon Sep 13 00:00:00 +0800 2010</created_at>
+
     <created_at>Fri Sep 04 00:00:00 +0800 2009</created_at>
 
     <following>false</following>
 
     <following>false</following>
 
     <verified>false</verified>
 
     <verified>false</verified>
 
     <allow_all_act_msg>false</allow_all_act_msg>
 
     <allow_all_act_msg>false</allow_all_act_msg>
     <geo_enabled>false</geo_enabled>
+
     <geo_enabled>true</geo_enabled>
  </user>
+
  <user>
+
    <id>1819424053</id>
+
    <screen_name>Kevinssolo</screen_name>
+
    <name>Kevinssolo</name>
+
    <province>11</province>
+
    <city>5</city>
+
    <location>北京 朝阳区</location>
+
    <description/>
+
    <url/>
+
    <profile_image_url>http://tp2.sinaimg.cn/1819424053/50/0</profile_image_url>
+
    <domain>kevinssolo</domain>
+
    <gender>m</gender>
+
    <followers_count>0</followers_count>
+
    <friends_count>20</friends_count>
+
    <statuses_count>1</statuses_count>
+
    <favourites_count>0</favourites_count>
+
    <created_at>Mon Sep 13 00:00:00 +0800 2010</created_at>
+
    <following>false</following>
+
    <verified>false</verified>
+
    <allow_all_act_msg>false</allow_all_act_msg>
+
    <geo_enabled>false</geo_enabled>
+
 
     <status>
 
     <status>
       <created_at>Mon Sep 13 17:52:38 +0800 2010</created_at>
+
       <created_at>Fri Dec 03 11:43:14 +0800 2010</created_at>
       <id>2591178727</id>
+
       <id>4049048423</id>
       <text>为了显示自己还在时尚这圈子里混被注册了微博,不会用,先注册了再说,省的好名字被抢,同时也能提醒自己还没老![鄙视]</text>
+
       <text>#818招行卡优商#原来在这里...http://sinaurl.cn/hbyXm3</text>
 
       <source>
 
       <source>
         <a href="http://t.sina.com.cn">新浪微博</a>
+
         <a href="http://all.vic.sina.com.cn/cmb/">招行信用卡8周年</a>
 
       </source>
 
       </source>
 
       <favorited>false</favorited>
 
       <favorited>false</favorited>
第98行: 第55行:
 
     </status>
 
     </status>
 
   </user>
 
   </user>
   <next_cursor>2</next_cursor> //仅在带了cursor参数后才有此字段
+
  ...
   <previous_cursor>0</previous_cursor> //仅在带了cursor参数后才有此字段
+
   <next_cursor>1</next_cursor>
 +
   <previous_cursor>0</previous_cursor>
 
</users>
 
</users>
 
</pre>
 
</pre>
====JSON====
+
===JSON示例===
 
<pre>
 
<pre>
 
{
 
{
  "users":[
+
    "users" :  
      {
+
    [
        "id":1644917462,
+
        {
        "screen_name":"大竹006",
+
            "name" : "Garfield_init",
        "name":"大竹006",
+
            "domain" : "uc11088",
        "province":"11",
+
            "geo_enabled" : true,
        "city":"1000",
+
            "followers_count" : 131,
        "location":"北京",
+
            "statuses_count" : 875,
        "description":"",
+
            "favourites_count" : 16,
        "url":"",
+
            "city" : "1",
        "profile_image_url":"http://tp3.sinaimg.cn/1644917462/50/0",
+
            "description" : "编号11088...",
        "domain":"",
+
            "verified" : false,
        "gender":"m",
+
            "status" :  
        "followers_count":0,
+
            {
        "friends_count":19,
+
                "created_at" : "Fri Dec 03 11:43:14 +0800 2010",
        "statuses_count":0,
+
                "text" : "#818招行卡优商#原来在这里...http://sinaurl.cn/hbyXm3",
        "favourites_count":0,
+
                "truncated" : false,
        "created_at":"Mon Sep 13 00:00:00 +0800 2010",
+
                "in_reply_to_status_id" : "",
        "following":false,
+
                "in_reply_to_screen_name" : "",
        "allow_all_act_msg":false,
+
                "geo" : null,
        "geo_enabled":false,
+
                "favorited" : false,
        "verified":false
+
                "in_reply_to_user_id" : "",
      },
+
                "id" : 4049048423,
      {
+
                "source" : "<a href=\"http://all.vic.sina.com.cn/cmb/\" rel=\"nofollow\">招行信用卡8周年</a>"
        "id":1819424053,
+
            },
        "screen_name":"Kevinssolo",
+
            "id" : 11088,
        "name":"Kevinssolo",
+
            "gender" : "m",
        "province":"11",
+
            "friends_count" : 97,
        "city":"5",
+
            "screen_name" : "Garfield_init",
        "location":"北京 朝阳区",
+
            "allow_all_act_msg" : false,
        "description":"",
+
            "following" : false,
        "url":"",
+
             "url" : "http://blog.sina.com.cn/gsj11088",
        "profile_image_url":"http://tp2.sinaimg.cn/1819424053/50/0",
+
             "profile_image_url" : "http://tp1.sinaimg.cn/11088/50/1291346587/1",
        "domain":"kevinssolo",
+
             "created_at" : "Fri Sep 04 00:00:00 +0800 2009",
        "gender":"m",
+
             "province" : "44",
        "followers_count":0,
+
             "location" : "广东 广州"
        "friends_count":20,
+
        },
        "statuses_count":1,
+
        ...
        "favourites_count":0,
+
    ],
        "created_at":"Mon Sep 13 00:00:00 +0800 2010",
+
    "next_cursor" : 1,
        "following":false,
+
    "previous_cursor" : 0
        "allow_all_act_msg":false,
+
        "geo_enabled":false,
+
        "verified":false,
+
        "status":{
+
             "created_at":"Mon Sep 13 17:52:38 +0800 2010",
+
             "id":2591178727,
+
            "text":"为了显示自己还在时尚这圈子里混被注册了微博,不会用,先注册了再说,省的好名字被抢,同时也能提醒自己还没老![鄙视]",
+
            "source":"<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>",
+
             "favorited":false,
+
            "truncated":false,
+
            "in_reply_to_status_id":"",
+
             "in_reply_to_user_id":"",
+
             "in_reply_to_screen_name":"",
+
            "geo":null
+
        }
+
      }
+
  ],
+
  "next_cursor":2, //仅在带了cursor参数后才有此字段
+
  "previous_cursor":0 //仅在带了cursor参数后才有此字段
+
 
}
 
}
</pre>
+
</pre>|
{{param_user}}
+
useAge=
{{param_status}}
+
* 注意,该接口不要求登录。如果没有登录,则每次最多只能返回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=
* xml:
+
===Java示例===
curl -u uid:password http://api.t.sina.com.cn/statuses/followers.xml?source=appkey
+
 
+
* json:
+
curl -u uid:password http://api.t.sina.com.cn/statuses/followers.json?source=appkey
+
 
+
====Java示例====
+
 
请从 [[SDK | 微博SDK开发包下载]] 下载Java SDK<br>
 
请从 [[SDK | 微博SDK开发包下载]] 下载Java SDK<br>
 
代码示例如下:
 
代码示例如下:
第219行: 第152行:
 
  }
 
  }
 
  }
 
  }
====PHP示例====
+
===PHP示例===
 
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br>  
 
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br>  
 
代码示例如下:
 
代码示例如下:
第245行: 第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个都不提供的情况下,系统返回当前登录用户的粉丝列表

注意事项

返回结果

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