Statuses/followers

跳转到: 导航, 搜索
(返回结果)
 
(未显示2个用户的4个中间版本)
第1行: 第1行:
== statuses/followers ==
+
{{api_desc2|
返回用户的粉丝列表,并返回粉丝的最新微博。按粉丝的关注时间倒序返回,每次返回100个,通过cursor参数来取得多于100的粉丝。注意目前接口最多只返回5000个粉丝。
+
uri=statuses/followers|
 
+
desc=获取用户粉丝列表及每个粉丝的最新一条微博,返回结果按粉丝的关注时间倒序排列,最新关注的粉丝排在最前面。每次返回20个,通过cursor参数来取得多于20的粉丝。注意目前接口最多只返回5000个粉丝。|
=== URL===
+
format=XML/JSON|
curl 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_list>
+
<users>
<users type="array">
+
 
   <user>
 
   <user>
  <id>11075</id>
+
    <id>11088</id>
  <screen_name>11075</screen_name>
+
    <screen_name>Garfield_init</screen_name>
  <name>11075</name>
+
    <name>Garfield_init</name>
  <province>广东</province>
+
    <province>44</province>
  <city>广州</city>
+
    <city>1</city>
  <location>广东 广州</location>
+
    <location>广东 广州</location>
  <description>blog: timyang.net</description>
+
    <description>编号11088...</description>
  <url>http://timyang.net</url>
+
    <url>http://blog.sina.com.cn/gsj11088</url>
  <profile_image_url>http://portrait.sinaimg.cn/11075/50#.jpg</profile_image_url>
+
    <profile_image_url>http://tp1.sinaimg.cn/11088/50/1291346587/1</profile_image_url>
  <domain></domain>
+
    <domain>uc11088</domain>
  <gender></gender>
+
    <gender>m</gender>
  <followers_count>0</followers_count>
+
    <followers_count>131</followers_count>
  <friends_count>0</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>Thu Jan 01 08:00:00 +0800 1970</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>
  <geo_enabled>false</geo_enabled>
+
    <allow_all_act_msg>false</allow_all_act_msg>
  <status>
+
    <geo_enabled>true</geo_enabled>
    <created_at>Fri Dec 25 17:57:27 +0800 2009</created_at>
+
    <status>
    <id>19093</id>
+
      <created_at>Fri Dec 03 11:43:14 +0800 2010</created_at>
    <text>测试中国</text>
+
      <id>4049048423</id>
    <source>
+
      <text>#818招行卡优商#原来在这里...http://sinaurl.cn/hbyXm3</text>
      <a id="0" href="http://t.sina.com.cn">Web</a>
+
      <source>
    </source>
+
        <a href="http://all.vic.sina.com.cn/cmb/">招行信用卡8周年</a>
    <favorited>false</favorited>
+
      </source>
    <truncated>false</truncated>
+
      <favorited>false</favorited>
    <geo/>
+
      <truncated>false</truncated>
    <in_reply_to_status_id></in_reply_to_status_id>
+
      <geo/>
    <in_reply_to_user_id></in_reply_to_user_id>
+
      <in_reply_to_status_id/>
    <in_reply_to_screen_name></in_reply_to_screen_name>
+
      <in_reply_to_user_id/>
  </status>
+
      <in_reply_to_screen_name/>
 +
    </status>
 
   </user>
 
   </user>
...................不分页没有此数据.................
+
  ...
   <next_cursor>1299072354878293926</next_cursor>
+
   <next_cursor>1</next_cursor>
 
   <previous_cursor>0</previous_cursor>
 
   <previous_cursor>0</previous_cursor>
..................................................
+
</users>
</users_list>
+
 
</pre>
 
</pre>
JSON示例:
+
===JSON示例===
 
<pre>
 
<pre>
  {"users":
+
{
  [{"id":9448,
+
    "users" :  
    "screen_name":"name_9448",
+
    [
    "name":"name_9448",
+
        {
    "province":"0",
+
            "name" : "Garfield_init",
    "city":"0",
+
            "domain" : "uc11088",
    "location":"",
+
            "geo_enabled" : true,
    "description":"",
+
            "followers_count" : 131,
    "url":"",
+
            "statuses_count" : 875,
    "profile_image_url":"http://tp1.sinaimg.cn/9448/50/0",
+
            "favourites_count" : 16,
    "domain":"9448",
+
            "city" : "1",
    "followers_count":30,
+
            "description" : "编号11088...",
    "friends_count":0,
+
            "verified" : false,
    "statuses_count":0,
+
            "status" :
    "favourites_count":0,
+
            {
    "created_at":"Thu Jan 01 08:00:00 +0800 1970",
+
                "created_at" : "Fri Dec 03 11:43:14 +0800 2010",
    "following":false,
+
                "text" : "#818招行卡优商#原来在这里...http://sinaurl.cn/hbyXm3",
    "geo_enabled":false,
+
                "truncated" : false,
    "verified":false},
+
                "in_reply_to_status_id" : "",
    {},
+
                "in_reply_to_screen_name" : "",
    ...
+
                "geo" : null,
  ]
+
                "favorited" : false,
...................不分页没有此数据.................
+
                "in_reply_to_user_id" : "",
  ,
+
                "id" : 4049048423,
  "next_cursor":2,
+
                "source" : "<a href=\"http://all.vic.sina.com.cn/cmb/\" rel=\"nofollow\">招行信用卡8周年</a>"
  "previous_cursor":0}
+
            },
..................................................
+
            "id" : 11088,
  }
+
            "gender" : "m",
</pre>
+
            "friends_count" : 97,
{{param_user}}
+
            "screen_name" : "Garfield_init",
{{param_status}}
+
            "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",
* xml:
+
            "created_at" : "Fri Sep 04 00:00:00 +0800 2009",
curl -u uid:password http://api.t.sina.com.cn/statuses/followers.xml?source=appkey
+
            "province" : "44",
 
+
            "location" : "广东 广州"
* json:
+
        },
curl -u uid:password http://api.t.sina.com.cn/statuses/followers.json?source=appkey
+
        ...
 
+
    ],
====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示例====
+
===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个都不提供的情况下,系统返回当前登录用户的粉丝列表

注意事项

返回结果

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