Statuses/followers

跳转到: 导航, 搜索
(是否需要身份验证)
 
(未显示5个用户的14个中间版本)
第1行: 第1行:
== statuses/followers ==
+
{{api_desc2|
返回用户的粉丝列表,并返回粉丝的最新微博。按粉丝的关注时间倒序返回,每次返回100个,通过cursor参数来取得多于100的粉丝。
+
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|
 +
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跟微博昵称,当二者一样而产生歧义的时候,建议使用该参数}}
 +
{{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=
 +
===XML示例===
 +
<pre>
 +
<?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>
 +
</pre>
 +
===JSON示例===
 +
<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",
 +
            "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
 +
}
 +
</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>
 +
代码示例如下:
 +
package weibo4j.examples;
 
   
 
   
=== 格式===
+
import java.util.List;
xml, json
+
import weibo4j.User;
 +
import weibo4j.Weibo;
 +
import weibo4j.WeiboException;
 
   
 
   
=== HTTP请求方式===
+
public class GetFollowers {
GET
+
 
   
 
   
=== 是否需要身份验证===
+
/**
true
+
* 返回用户关注对象列表,并返回最新微博文章。
 
+
* @param args
=== 请求数限制===
+
*/
true
+
public static void main(String[] args) {
 
+
System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
=== 请求参数===
+
    System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);
* id.  选填参数.  要获取粉丝的 UID或微博昵称 
+
try {
o 示例: http://api.t.sina.com.cn/statuses/followers/12345.json or http://api.t.sina.com.cn/statuses/followers/bob.xml
+
Weibo weibo = getWeibo(false,args);
* user_id. 选填参数.  要获取的UID
+
List<User> list = weibo.getFollowersStatuses();
o 示例: http://api.t.sina.com.cn/statuses/followers.xml?user_id=1401881
+
for(User user : list) {
* screen_name.  选填参数.  要获取的微博昵称
+
System.out.println(user.toString());
o 示例: http://api.t.sina.com.cn/statuses/followers.xml?screen_name=101010
+
}
* cursor. 选填参数. 单页只能包含100个粉丝列表,为了获取更多则cursor默认从-1开始,通过增加或减少cursor来获取更多的粉丝列表
+
} catch (WeiboException e) {
o 示例: http://api.t.sina.com.cn/statuses/followers/barackobama.xml?cursor=-1
+
e.printStackTrace();
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
+
 
+
private static Weibo getWeibo(boolean isOauth,String[] args) {
=== 使用说明===
+
Weibo weibo = new Weibo();
* 为了保护用户隐私,只有用户设置了公开或对粉丝设置了公开的数据才会返回。
+
if(isOauth) {//oauth验证方式 args[0]:访问的token;args[1]:访问的密匙
* 如果没有提供cursor参数,将只返回最前面的100个关注列表
+
weibo.setToken(args[0], args[1]);
 
+
}else {//用户登录方式
=== 返回结果 ===
+
    weibo.setUserId(args[0]);//用户名/ID
XML示例:
+
    weibo.setPassword(args[1]);//密码
<?xml version="1.0" encoding="UTF-8"?>
+
}
<users_list>
+
return weibo;
<users type="array">
+
}
  <user>
+
  }
  <id>11075</id>
+
===PHP示例===
  <screen_name>11075</screen_name>
+
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br>
  <name>11075</name>
+
代码示例如下:
  <province>广东</province>
+
<pre>
  <city>广州</city>
+
//Statuses/followers
  <location>广东 广州</location>
+
//返回用户关注对象列表,并返回最新微博文章。
  <description>blog: timyang.net</description>
+
$c = new WeiboClient( WB_AKEY ,
  <profile_image_url>http://portrait.sinaimg.cn/11075/50#.jpg</profile_image_url>
+
                      WB_SKEY ,
  <domain></domain>
+
                      $_SESSION['last_key']['oauth_token'] ,
  <gender></gender>
+
                      $_SESSION['last_key']['oauth_token_secret']  );
  <email></email>
+
  <qq></qq>
+
  <msn></msn>
+
  <followers_count>0</followers_count>
+
  <friends_count>0</friends_count>
+
  <statuses_count>0</statuses_count>
+
  <favourites_count>0</favourites_count>
+
  <created_at>Thu Jan 01 08:00:00 +0800 1970</created_at>
+
  <following>false</following>
+
  <verified>false</verified>
+
  <geo_enabled>false</geo_enabled>
+
  <status>
+
    <created_at>Fri Dec 25 17:57:27 +0800 2009</created_at>
+
    <id>19093</id>
+
    <text>测试中国</text>
+
    <source>
+
      <a id="0" href="http://t.sina.com.cn">Web</a>
+
    </source>
+
    <favorited>false</favorited>
+
    <truncated>false</truncated>
+
    <geo/>
+
    <in_reply_to_status_id></in_reply_to_status_id>
+
    <in_reply_to_user_id></in_reply_to_user_id>
+
    <in_reply_to_screen_name></in_reply_to_screen_name>
+
  </status>
+
  </user>
+
...................不分页没有此数据.................
+
  <next_cursor>1299072354878293926</next_cursor>
+
  <previous_cursor>0</previous_cursor>
+
..................................................
+
</users_list>
+
 
+
JSON示例:
+
 
+
  {"users":
+
  [{"id":9448,
+
    "screen_name":"name_9448",
+
    "name":"name_9448",
+
    "province":"0",
+
    "city":"0",
+
    "location":"",
+
    "description":"",
+
    "profile_image_url":"http://tp1.sinaimg.cn/9448/50/0",
+
    "domain":"9448",
+
    "email":"",
+
    "qq":"3854",
+
    "msn":"msn_3854",
+
    "followers_count":30,
+
    "friends_count":0,
+
    "statuses_count":0,
+
    "favourites_count":0,
+
    "created_at":"Thu Jan 01 08:00:00 +0800 1970",
+
    "following":false,
+
    "geo_enabled":false,
+
    "verified":false},
+
    {},
+
    ...
+
  ]
+
...................不分页没有此数据.................
+
  ,
+
  "next_cursor":2,
+
  "previous_cursor":0}
+
  ..................................................
+
  }
+
 
+
=== 使用示例===
+
 
+
* xml:
+
 
+
curl -u user:password http://api.t.sina.com.cn/statuses/followers.xml
+
 
+
* json:
+
  
curl -u user:password http://api.t.sina.com.cn/statuses/followers.json
+
//用户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'].' ;');
 +
}
 +
</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