Statuses/friends timeline

跳转到: 导航, 搜索
(返回结果)
 
(未显示2个用户的15个中间版本)
第1行: 第1行:
== statuses/friends_timeline ==
+
{{api_desc2|
返回用户所有关注用户最新n条微博信息。和用户“我的首页”返回内容相同。
+
uri=statuses/friends_timeline|
 
+
desc=获取当前登录用户及其所关注用户的最新微博消息。和用户登录 http://t.sina.com.cn 后在“我的首页”中看到的内容相同。<br/>别名statuses/home_timeline|
===URL===
+
format=XML/JSON|
http://api.t.sina.com.cn/statuses/friends_timeline.format
+
httpMethod=GET|
or
+
needAuth=true|
http://api.t.sina.com.cn/statuses/home_timeline.format
+
rateLimit=true|
 
+
params={{api_args|since_id|false|int64|若指定此参数,则只返回ID比since_id大的微博消息(即比since_id发表时间晚的微博消息)。}}
===格式===
+
{{api_args|max_id|false|int64|若指定此参数,则返回ID小于或等于max_id的微博消息}}
xml, json
+
{{api_args|count|false|int,默认值20,最大值100。|指定要返回的记录条数。}}
+
{{api_args|page|false|int,默认值1。|指定返回结果的页码。根据当前登录用户所关注的用户数及这些被关注用户发表的微博数,翻页功能最多能查看的总记录数会有所不同,通常最多能查看1000条左右。}}
===HTTP请求方式===
+
{{api_args|base_app|false|int|是否基于当前应用来获取数据。1为限制本应用微博,0为不做限制。}}
GET
+
{{api_args|feature|false|int|微博类型,0全部,1原创,2图片,3视频,4音乐. 返回指定类型的微博信息内容。}}|
+
getParam=&count=5&page=10|
===是否需要登录===
+
postParam=|
true
+
result=
+
===XML示例===
===请求参数===
+
<pre>
* since_id:  可选参数(微博信息ID). 只返回ID比since_id大(比since_id时间晚的)的微博信息内容。
+
<?xml version="1.0" encoding="UTF-8"?>
:o 示例: http://api.t.sina.com.cn/statuses/friends_timeline.xml?since_id=12345
+
<statuses>
* max_id: 可选参数(微博信息ID).  返回ID不大于max_id的微博信息内容。
+
  <status>
:o 示例: http://api.t.sina.com.cn/statuses/friends_timeline.xml?max_id=54321
+
     <created_at>Tue Nov 30 15:36:28 +0800 2010</created_at>
* count:  可选参数.  每次返回的最大记录数,不能超过200,默认20.
+
     <id>3979831859</id>
:o 示例: http://api.t.sina.com.cn/statuses/friends_timeline.xml?count=5  
+
     <text>ewvxe</text>
* page: 可选参数. 返回结果的页序号。注意:有分页限制。根据用户关注对象发表的数量,通常最多返回1,000条最新微博分页内容, 默认1
+
:o 示例: http://api.t.sina.com.cn/statuses/friends_timeline.xml?page=3
+
 
+
===返回结果===
+
XML示例:
+
<?xml version="1.0" encoding="UTF-8"?>
+
<statuses>
+
<status>
+
     <created_at>Fri Dec 25 13:07:17 +0800 2009</created_at>
+
     <id>14265</id>
+
     <text>在群星之中,有一颗星是指导着我的生命通过不可知的黑暗的。 </text>
+
 
     <source>
 
     <source>
       <a id="0" href="http://t.sina.com.cn">Web</a>
+
       <a href="">微博开放平台接口</a>
 
     </source>
 
     </source>
 
     <favorited>false</favorited>
 
     <favorited>false</favorited>
 
     <truncated>false</truncated>
 
     <truncated>false</truncated>
 
     <geo/>
 
     <geo/>
     <in_reply_to_status_id></in_reply_to_status_id>
+
     <in_reply_to_status_id/>
     <in_reply_to_user_id></in_reply_to_user_id>
+
     <in_reply_to_user_id/>
     <in_reply_to_screen_name></in_reply_to_screen_name>
+
     <in_reply_to_screen_name/>
    <thumbnail_pic>http://static16.photo.sina.com.cn/thumbnail/62988d06tcbbc377f7bbf</thumbnail_pic>
+
    <bmiddle_pic>http://static16.photo.sina.com.cn/bmiddle/62988d06tcbbc377f7bbf</bmiddle_pic>
+
    <original_pic>http://static16.photo.sina.com.cn/orignal/62988d06tcbbc377f7bbf</original_pic>
+
 
     <user>
 
     <user>
       <id>6719</id>
+
       <id>1854740027</id>
       <screen_name>name_6719</screen_name>
+
       <screen_name>siegetest</screen_name>
       <name>name_6719</name>
+
       <name>siegetest</name>
       <province></province>
+
       <province>11</province>
       <city></city>
+
       <city>8</city>
       <location></location>
+
       <location>北京 海淀区</location>
       <description></description>
+
       <description>ABCDE</description>
       <url>http://timyang.net</url>
+
       <url/>
       <profile_image_url>http://tp4.sinaimg.cn/6719/50/0</profile_image_url>
+
       <profile_image_url>http://tp4.sinaimg.cn/1854740027/50/0/1</profile_image_url>
       <domain>6719</domain>
+
       <domain/>
       <gender></gender>
+
       <gender>m</gender>
       <followers_count>18</followers_count>
+
       <followers_count>3</followers_count>
       <friends_count>30</friends_count>
+
       <friends_count>20</friends_count>
       <statuses_count>0</statuses_count>
+
       <statuses_count>15</statuses_count>
 
       <favourites_count>0</favourites_count>
 
       <favourites_count>0</favourites_count>
       <created_at>Thu Jan 01 08:00:00 +0800 1970</created_at>
+
       <created_at>Thu Nov 11 00:00:00 +0800 2010</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>
 +
      <geo_enabled>true</geo_enabled>
 
     </user>
 
     </user>
 
   </status>
 
   </status>
  ...
+
...
  </statuses>
+
</statuses>
 +
</pre>
 +
===JSON示例===
 +
<pre>
 +
[
 +
    {
 +
        "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" :
 +
            [
  
JSON:示例
+
            ],
 +
            "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" :
 +
        [
  
  [
+
        ],
  {"created_at":"Wed Jan 06 15:46:42 +0800 2010",
+
        "in_reply_to_screen_name" : "",
    "id":142272,
+
        "geo" : null,
    "text":"ttfffff asf",
+
        "user" :  
    "source":"<a id=\"0\" href=\"http://t.sina.com.cn/\" rel=\"nofollow\">Web</a>",
+
        {
    "favorited":false,
+
            "name" : "半拉拖鞋",
    "truncated":false,
+
            "domain" : "banlatuoxie",
    "in_reply_to_status_id":"",
+
            "geo_enabled" : true,
    "in_reply_to_user_id":"",
+
            "followers_count" : 56,
    "in_reply_to_screen_name":"",
+
            "statuses_count" : 333,
    "geo":null,
+
            "favourites_count" : 1,
    "user":{<br/>      "id":11075,
+
            "city" : "5",
        "screen_name":"name_11075",
+
            "description" : "在这里,我只管把话发出去,有没有人理就不管我的事了!",
        "name":"name_11075",
+
            "verified" : false,
        "province":null,
+
            "id" : 1799824787,
        "city":null,
+
            "gender" : "m",
        "location":"",
+
            "friends_count" : 76,
        "description":"",
+
            "screen_name" : "半拉拖鞋",
        "url":"",
+
            "allow_all_act_msg" : false,
        "profile_image_url":"http://tp4.sinaimg.cn/11075/50/0",
+
            "following" : false,
        "domain":"11075",
+
            "url" : "http://blog.sina.com.cn/lingdianjingq",
        "followers_count":28,
+
            "profile_image_url" : "http://tp4.sinaimg.cn/1799824787/50/1289443070/1",
        "friends_count":50,
+
            "created_at" : "Sun Sep 05 00:00:00 +0800 2010",
        "statuses_count":0,
+
            "province" : "11",
         "favourites_count":26,
+
            "location" : "北京 朝阳区"
         "created_at":"Thu Jan 01 08:00:00 +0800 1970",
+
        },
         "following":false,
+
         "favorited" : false,
         "geo_enabled":false,
+
         "in_reply_to_user_id" : "",
        "verified":true}
+
         "id" : 3980654229,
    }
+
         "source" : "<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>"
    ,{}
+
    },
    ,...
+
...
  ]
+
]
{{Param_status}}
+
</pre>|
{{Param_user}}
+
useAge=无|
 
+
otherInfo=
===使用示例===
+
===Java示例===
需修改appkey
+
* xml:
+
curl -u uid:password http://api.t.sina.com.cn/statuses/friends_timeline.xml?source=appkey
+
 
+
* json:
+
curl -u uid:password http://api.t.sina.com.cn/statuses/friends_timeline.json?source=appkey
+
 
+
====Java示例====
+
 
请从 [[SDK | 微博SDK开发包下载]] 下载Java SDK<br>
 
请从 [[SDK | 微博SDK开发包下载]] 下载Java SDK<br>
 
代码示意如下:
 
代码示意如下:
 
+
<pre>
 
  package weibo4j.examples;
 
  package weibo4j.examples;
 
   
 
   
第161行: 第189行:
 
  }
 
  }
 
  }
 
  }
====PHP示例====
+
</pre>
 +
===PHP示例===
 
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br>  
 
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br>  
 
代码示例如下:
 
代码示例如下:
第187行: 第216行:
 
}
 
}
 
</pre>
 
</pre>
 +
}}

2012年2月20日 (一) 18:25的最后版本

目录

statuses/friends_timeline

获取当前登录用户及其所关注用户的最新微博消息。和用户登录 http://t.sina.com.cn 后在“我的首页”中看到的内容相同。
别名statuses/home_timeline

URL

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

支持格式

XML/JSON

HTTP请求方式

GET

是否需要登录

true
关于授权机制,参见授权机制声明

请求数限制

true
关于请求数限制,参见接口访问权限说明

请求参数

  必选 类型及范围 说明
source true string 申请应用时分配的AppKey,调用接口时候代表应用的唯一身份。(采用OAuth授权方式不需要此参数)
since_id false int64 若指定此参数,则只返回ID比since_id大的微博消息(即比since_id发表时间晚的微博消息)。
max_id false int64 若指定此参数,则返回ID小于或等于max_id的微博消息
count false int,默认值20,最大值100。 指定要返回的记录条数。
page false int,默认值1。 指定返回结果的页码。根据当前登录用户所关注的用户数及这些被关注用户发表的微博数,翻页功能最多能查看的总记录数会有所不同,通常最多能查看1000条左右。
base_app false int 是否基于当前应用来获取数据。1为限制本应用微博,0为不做限制。
feature false int 微博类型,0全部,1原创,2图片,3视频,4音乐. 返回指定类型的微博信息内容。

注意事项

返回结果

XML示例

<?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示例

[
    {
        "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>"
    },
...
]

其他

Java示例

请从 微博SDK开发包下载 下载Java SDK
代码示意如下:

 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示例

请从 微博SDK开发包下载 处下载PHP SDK(支持OAuth验证之版本)
代码示例如下:

//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.";";
}
文档更新时间: 2012-02-20