Statuses/friends timeline
第1行: | 第1行: | ||
{{api_desc2| | {{api_desc2| | ||
uri=statuses/friends_timeline| | uri=statuses/friends_timeline| | ||
− | desc= | + | desc=获取当前登录用户及其所关注用户的最新微博消息。和用户登录http://t.sina.com.cn/后在“我的首页”中看到的内容相同。| |
format=XML/JSON| | format=XML/JSON| | ||
httpMethod=GET| | httpMethod=GET| | ||
第9行: | 第9行: | ||
{{api_args|max_id|false|int64|若指定此参数,则返回ID小于或等于max_id的微博消息}} | {{api_args|max_id|false|int64|若指定此参数,则返回ID小于或等于max_id的微博消息}} | ||
{{api_args|count|false|int,默认值20,最大值200。|指定要返回的记录条数。}} | {{api_args|count|false|int,默认值20,最大值200。|指定要返回的记录条数。}} | ||
− | {{api_args|page|false|int,默认值1。| | + | {{api_args|page|false|int,默认值1。|指定返回结果的页码。根据当前登录用户所关注的用户数及这些被关注用户发表的微博数,翻页功能最多能查看的总记录数会有所不同,通常最多能查看1000条左右。}}| |
getParam=count=5&page=10| | getParam=count=5&page=10| | ||
postParam=| | postParam=| |
2010年12月1日 (三) 11:00的版本
目录 |
statuses/friends_timeline
获取当前登录用户及其所关注用户的最新微博消息。和用户登录http://t.sina.com.cn/后在“我的首页”中看到的内容相同。
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,最大值200。 | 指定要返回的记录条数。 |
page | false | int,默认值1。 | 指定返回结果的页码。根据当前登录用户所关注的用户数及这些被关注用户发表的微博数,翻页功能最多能查看的总记录数会有所不同,通常最多能查看1000条左右。 |
注意事项
无
返回结果
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.";"; }