Statuses/followers

跳转到: 导航, 搜索
 
(未显示7个用户的25个中间版本)
第1行: 第1行:
== statuses/followers ==
+
{{api_desc2|
返回用户的粉丝列表,并返回粉丝的最新微博。按粉丝的关注时间倒序返回,每次返回100个,通过cursor参数来取得多于100的粉丝。
+
uri=statuses/followers|
 
+
desc=获取用户粉丝列表及每个粉丝的最新一条微博,返回结果按粉丝的关注时间倒序排列,最新关注的粉丝排在最前面。每次返回20个,通过cursor参数来取得多于20的粉丝。注意目前接口最多只返回5000个粉丝。|
Returns the authenticating user's followers, each with current status inline. They are ordered by the order in which they followed the user, 100 at a time. (Please note that the result set isn't guaranteed to be 100 every time as suspended users will be filtered out.) Use the cursor option to access earlier followers.
+
format=XML/JSON|
 
+
httpMethod=GET|
=== URL===
+
needAuth=false|
curl http://api.t.sina.com.cn/statuses/followers.format
+
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
+
 
   
 
   
=== 是否需要身份验证===
+
/**
false unless requesting it from a protected user; if getting this data of a protected user, you must auth (and be allowed to see that user).
+
* 返回用户关注对象列表,并返回最新微博文章。
+
* @param args
=== 请求数限制===
+
*/
1 call per request
+
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 Example: 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 Example: http://api.t.sina.com.cn/statuses/followers.xml?user_id=1401881
+
for(User user : list) {
* screen_name.  选填参数.  要获取的账户ID 
+
System.out.println(user.toString());
o Example: http://api.t.sina.com.cn/statuses/followers.xml?screen_name=101010
+
}
* cursor. 选填参数. 单页只能包含100个粉丝列表,为了获取更多则cursor默认从-1开始,通过增加或减少cursor来获取更多的粉丝列表
+
} catch (WeiboException e) {
o Example: http://api.t.sina.com.cn/statuses/followers/barackobama.xml?cursor=-1
+
e.printStackTrace();
o Example: http://api.t.sina.com.cn/statuses/followers/barackobama.xml?cursor=1300794057949944903
+
}
 
+
}
 
+
=== 使用说明===
+
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]);
XML示例:
+
}else {//用户登录方式
<?xml version="1.0" encoding="UTF-8"?>
+
    weibo.setUserId(args[0]);//用户名/ID
<users>
+
    weibo.setPassword(args[1]);//密码
  <user>
+
}
  <id>1401881</id>
+
return weibo;
  <name>Doug Williams</name>
+
}
  <screen_name>dougw</screen_name>
+
  }
  <location>San Francisco, CA</location>
+
===PHP示例===
  <description>Sina API Support. Internet, greed, users, dougw and opportunities are my passions.</description>
+
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br>  
  <profile_image_url>http://sinaimg.cn/avatar.png</profile_image_url>
+
代码示例如下:
  <url>http://www.igudo.com</url>
+
<pre>
  <protected>false</protected>
+
//Statuses/followers
  <followers_count>1031</followers_count>
+
//返回用户关注对象列表,并返回最新微博文章。
  <profile_background_color>9ae4e8</profile_background_color>
+
$c = new WeiboClient( WB_AKEY ,
  <profile_text_color>000000</profile_text_color>
+
                      WB_SKEY ,
  <profile_link_color>0000ff</profile_link_color>
+
                      $_SESSION['last_key']['oauth_token'] ,
  <profile_sidebar_fill_color>e0ff92</profile_sidebar_fill_color>
+
                      $_SESSION['last_key']['oauth_token_secret'] );
  <profile_sidebar_border_color>87bc44</profile_sidebar_border_color>
+
  <friends_count>293</friends_count>
+
  <created_at>Sun Mar 18 06:42:26 +0000 2007</created_at>
+
  <favourites_count>0</favourites_count>
+
  <utc_offset>-18000</utc_offset>
+
  <time_zone>Eastern Time (US & Canada)</time_zone>
+
 
+
  <profile_background_tile>false</profile_background_tile>
+
  <statuses_count>3390</statuses_count>
+
  <notifications>false</notifications>
+
  <following>false</following>
+
  <verified>true</verified>
+
  <status>
+
  <created_at>Tue Apr 07 22:52:51 +0000 2009</created_at>
+
  <id>1472669360</id>
+
  <text>At least I can get your humor through  I don't mean this in a bad way, but genetically speaking your a cul-de-sac.</text>
+
  <source><a href="http://t.sina.com.cn/">MSN机器人</a></source>
+
  <truncated>false</truncated>
+
  <in_reply_to_status_id></in_reply_to_status_id>
+
  <in_reply_to_user_id></in_reply_to_user_id>
+
  <favorited>false</favorited>
+
  <in_reply_to_screen_name></in_reply_to_screen_name>
+
  </status>
+
  </user>
+
  ... truncated ...
+
</users>
+
 
+
=== 分页返回 ===
+
XML示例:
+
<?xml version="1.0" encoding="UTF-8"?>
+
<users_list>
+
<users type="array">
+
<user>
+
  <id>422</id>
+
  <name>Jason Shellen</name>
+
  <screen_name>shellen</screen_name>
+
  <location>iPhone: 37.889321,-122.173345</location>
+
  <description>CEO and founder of Thing Labs, makers of Brizzly! Former Blogger/Google dude, father of two little dudes.</description>
+
  <profile_image_url>http://sinaimg.cn/avatar.png</profile_image_url>
+
  <url>http://www.shellen.com</url>
+
  <protected>false</protected>
+
  <followers_count>8526</followers_count>
+
  <profile_background_color>9ae4e8</profile_background_color>
+
  <profile_text_color>000000</profile_text_color>
+
  <profile_link_color>0000ff</profile_link_color>
+
  <profile_sidebar_fill_color>DCDCDC</profile_sidebar_fill_color>
+
  <profile_sidebar_border_color>D22900</profile_sidebar_border_color>
+
  <friends_count>375</friends_count>
+
  <created_at>Thu Jul 06 22:36:22 +0000 2006</created_at>
+
  <favourites_count>1179</favourites_count>
+
  <utc_offset>-28800</utc_offset>
+
  <time_zone>Pacific Time (US & Canada)</time_zone>
+
  <profile_background_image_url>http://a1.twimg.com/profile_background_images/382/IMG_0158.jpg</profile_background_image_url>
+
  <profile_background_tile>true</profile_background_tile>
+
  <statuses_count>2710</statuses_count>
+
  <notifications></notifications>
+
  <verified>false</verified>
+
  <following></following>
+
  <status>
+
    <created_at>Thu Sep 24 19:31:58 +0000 2009</created_at>
+
    <id>4349531340</id>
+
    <text>I think @jasonfried just went from "prickly fellow" to "kind of a dick" in my book. Eyes on your own paper Fried.</text>
+
    <source><a href="http://www.brizzly.com" rel="nofollow">Brizzly</a></source>
+
    <truncated>false</truncated>
+
    <in_reply_to_status_id></in_reply_to_status_id>
+
    <in_reply_to_user_id></in_reply_to_user_id>
+
    <favorited>false</favorited>
+
    <in_reply_to_screen_name></in_reply_to_screen_name>
+
  </status>
+
  </user>
+
... truncated ...
+
</users>
+
<next_cursor>1299072354878293926</next_cursor>
+
<previous_cursor>0</previous_cursor>
+
</users_list>
+
 
+
=== 说明===
+
* 如果没有提供cursor参数,将只返回最前面的100个关注列表
+
 
+
=== 使用示例===
+
cURL:
+
  
curl -u user:password http://api.t.sina.com.cn/statuses/followers.xml
+
//用户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