Statuses/followers/en

跳转到: 导航, 搜索

目录

statuses/followers

eturn follower list and the latest weibo of each follower. The responses if sort by time, and the newest follower is at the top. 20 records are returned in one call, you can use cursor for more than 20 followers, but it still has a 5000 limitation.

URL

http://api.t.sina.com.cn/statuses/followers.(json%7Cxml)

Supported Formats

XML/JSON

HTTP Request Method

GET

Requires Authentication

false
See the Authorization Mechanism Statement for authorization details

Requests Count Limitation

true
See the Interface Access Rights Statement for the Request Count Limitaiton details.

Request Parameters

  Requires Type and Range Description
source true string AppKey for the application to identify it. ( This parameter is not needed when using OAuth)
:id false int64/string Return the weibos of specified ID (int64) or nickname(string) of a user. This is a RESTful parameter, please see Notes
user_id false int64 Return the weibos of specified ID of a user. It is mainly used to distinguish user ID with weibo nickname(screen_name). When weibo nickname is numbers and leads ambiguity with user ID, especially when weibo nickname and user ID are the same, using this parameter is recommended.
screen_name false string Weibo nickname. It is mainly used to distinguish user UID and weibo nickname. When they both are the same and lead ambiguity, using this parameter is recommended.
cursor false int Used for page request. Passes -1 for requesting the 1st page, next_cursor is returned for cursor of netxt page. It is at the end of the record when next_cursor is 0.
count false Int, default is 20, max is 200. Max record count return in one page, 200 is the max, 20 by default.
You can select one of :id, user_id and screen_name. It returns following list of authenticating user if none of these three parameters is provided.

Notes

Example Request

XML
curl -u "username:password" "http://api.t.sina.com.cn/statuses/followers.xml?source=appkey&user_id=11051"
JSON
curl -u "username:password" "http://api.t.sina.com.cn/statuses/followers.json?source=appkey&user_id=11051"

Response

XML Example

<?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 Example

{
    "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
}

Others

Java Example

Please download Java SDK from . Weibo SDK Development Kit Dowload Site
Sample Code:

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 Example

Please download PHP SDK with OAUTH supported from Weibo SDK Development Kit Dowload Site
. Sample Code:

//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'].' ;');
}



文档更新时间: 2011-01-20