Statuses/friends timeline/en

Jump to: navigation, search

Contents

statuses/friends_timeline

Return latest weibo of the authenticating user and his followings. It’s the same with the contents of the “Home” page when user authenticated. Alias API: statuses/home_timline

URL

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

Supported Formats

XML/JSON

HTTP Request Method

GET

Requires Authentication

true
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)
since_id false int64 Returns then weibos with an ID greater than (that is, more recent than) the specified ID
max_id false int64 Return the weibos with an ID smaller than the specified ID.
count false int,default is 20,max is 200. Specify the number of weibos return.
page false int,default is 1. Specify results page. Based on the number of the authenticating user’s followings and the number of the followings’s weibos, the max number of weibos that page feature can access is different, usually up to about 1000 piceces.
base_app false int whether get the data based on current application. 1 is only current application; 0 is no limitation.
feature false int Return the weibos by weibo type. 0 is all type. 1 is original. 2 is picture. 3 is video. 4 is music.

Notes

None

Example Request

XML
curl -u "username:password" "http://api.t.sina.com.cn/statuses/friends_timeline.xml?source=appkey&count=5&page=10"
JSON
curl -u "username:password" "http://api.t.sina.com.cn/statuses/friends_timeline.json?source=appkey&count=5&page=10"

Response

XML Example

<?xml version="1.0" encoding="UTF-8"?>
<statuses>
  <status>
    <created_at>Tue Nov 30 15:36:28 +0800 2010</created_at>
    <id>3979831859</id>
    <text>ewvxe</text>
    <source>
      <a href="">微博开放平台接口</a>
    </source>
    <favorited>false</favorited>
    <truncated>false</truncated>
    <geo/>
    <in_reply_to_status_id/>
    <in_reply_to_user_id/>
    <in_reply_to_screen_name/>
    <user>
      <id>1854740027</id>
      <screen_name>siegetest</screen_name>
      <name>siegetest</name>
      <province>11</province>
      <city>8</city>
      <location>北京 海淀区</location>
      <description>ABCDE</description>
      <url/>
      <profile_image_url>http://tp4.sinaimg.cn/1854740027/50/0/1</profile_image_url>
      <domain/>
      <gender>m</gender>
      <followers_count>3</followers_count>
      <friends_count>20</friends_count>
      <statuses_count>15</statuses_count>
      <favourites_count>0</favourites_count>
      <created_at>Thu Nov 11 00:00:00 +0800 2010</created_at>
      <following>false</following>
      <verified>false</verified>
      <allow_all_act_msg>false</allow_all_act_msg>
      <geo_enabled>true</geo_enabled>
    </user>
  </status>
...
</statuses>

JSON Example

[
    {
        "created_at" : "Tue Nov 30 16:21:13 +0800 2010",
        "text" : "转发微博。",
        "truncated" : false,
        "retweeted_status" : 
        {
            "created_at" : "Tue Nov 30 16:05:41 +0800 2010",
            "text" : "对待事物的出发点、立足点,决定着事物的发展及发展后的结果。这个结果实际也是一种相对而言的成败。世俗间追求这种成败却又调整不好出发点,更是找不到立足点。所以成也好败也好,放下了最好。",
            "truncated" : false,
            "in_reply_to_status_id" : "",
            "annotations" : 
            [

            ],
            "in_reply_to_screen_name" : "",
            "geo" : null,
            "user" : 
            {
                "name" : "归元隆印",
                "domain" : "",
                "geo_enabled" : true,
                "followers_count" : 66710,
                "statuses_count" : 77,
                "favourites_count" : 0,
                "city" : "1",
                "description" : "心存慈悲 身奉善行 出世入世 修己助人 归元禅寺官方网站:http://www.guiyuanchansi.net",
                "verified" : true,
                "id" : 1799833402,
                "gender" : "m",
                "friends_count" : 4,
                "screen_name" : "归元隆印",
                "allow_all_act_msg" : false,
                "following" : false,
                "url" : "http://1",
                "profile_image_url" : "http://tp3.sinaimg.cn/1799833402/50/1283207796",
                "created_at" : "Tue Aug 24 00:00:00 +0800 2010",
                "province" : "42",
                "location" : "湖北 武汉"
            },
            "favorited" : false,
            "in_reply_to_user_id" : "",
            "id" : 3980364843,
            "source" : "<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>"
        },
        "in_reply_to_status_id" : "",
        "annotations" : 
        [

        ],
        "in_reply_to_screen_name" : "",
        "geo" : null,
        "user" : 
        {
            "name" : "半拉拖鞋",
            "domain" : "banlatuoxie",
            "geo_enabled" : true,
            "followers_count" : 56,
            "statuses_count" : 333,
            "favourites_count" : 1,
            "city" : "5",
            "description" : "在这里,我只管把话发出去,有没有人理就不管我的事了!",
            "verified" : false,
            "id" : 1799824787,
            "gender" : "m",
            "friends_count" : 76,
            "screen_name" : "半拉拖鞋",
            "allow_all_act_msg" : false,
            "following" : false,
            "url" : "http://blog.sina.com.cn/lingdianjingq",
            "profile_image_url" : "http://tp4.sinaimg.cn/1799824787/50/1289443070/1",
            "created_at" : "Sun Sep 05 00:00:00 +0800 2010",
            "province" : "11",
            "location" : "北京 朝阳区"
        },
        "favorited" : false,
        "in_reply_to_user_id" : "",
        "id" : 3980654229,
        "source" : "<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>"
    },
...
]

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.Status;
 import weibo4j.Weibo;
 import weibo4j.WeiboException;
 
 public class GetFriendsTimeline {
 	/**
 	 * 获取当前用户所关注用户的最新微博信息 (别名: statuses/home_timeline) 
 	 * @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 {
 			//获取前20条关注用户的微博信息
 			List<Status> statuses = getWeibo(true,args).getFriendsTimeline();
 			for (Status status : statuses) {
 	            System.out.println(status.getUser().getName() + ":" +
 	                               status.getText());
 	        }
 		} 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/friends timeline
//获取前20条最新更新的公共微博消息
$c = new WeiboClient( WB_AKEY , 
                      WB_SKEY , 
                      $_SESSION['last_key']['oauth_token'] , 
                      $_SESSION['last_key']['oauth_token_secret']  );

$msg  = $c->friends_timeline();
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 $data){
	$user_name = $data['user']['name'];
	$text = $data['text'];
	echo $user_name."=".$text.";";
}



文档更新时间: 19 January 2011