Statuses/friends/en

跳转到: 导航, 搜索

目录

statuses/friends

Return following list with the latest status of each following. The responses is in chronological reverse order, and the latest following is at the top.

URL

http://api.t.sina.com.cn/statuses/friends.(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)
:id false int64/string User ID (int64) or nickname(string). This is a RESTful parameter. See Notes for examples.
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. Count of weibo returned for one page. Default is 20, max is 200.
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/friends.xml?source=appkey&user_id=11051"
JSON
curl -u "username:password" "http://api.t.sina.com.cn/statuses/friends.json?source=appkey&user_id=11051"

Response

XML Example

<?xml version="1.0" encoding="UTF-8"?>
<users>
  <user>
    <id>1473612611</id>
    <screen_name>周立清</screen_name>
    <name>周立清</name>
    <province>14</province>
    <city>1</city>
    <location>山西 太原</location>
    <description>新浪微博开放平台(open.t.sina.com.cn),欢迎广大站长朋友前来聊聊:13718188488 、 010-62676120 、QQ:3653550、liqing3@staff.sina.com.cn</description>
    <url>http://www.linger.cn</url>
    <profile_image_url>http://tp4.sinaimg.cn/1473612611/50/1284048157/1</profile_image_url>
    <domain>xyzlinger</domain>
    <gender>m</gender>
    <followers_count>4652</followers_count>
    <friends_count>1060</friends_count>
    <statuses_count>3897</statuses_count>
    <favourites_count>5</favourites_count>
    <created_at>Fri Aug 28 00:00:00 +0800 2009</created_at>
    <following>false</following>
    <verified>true</verified>
    <allow_all_act_msg>true</allow_all_act_msg>
    <geo_enabled>true</geo_enabled>
    <remark/>
    <status>
      <created_at>Fri Dec 03 13:49:07 +0800 2010</created_at>
      <id>4051881415</id>
      <text>哈哈,看到新浪@微博大屏幕 了[哈哈],第一条是@飞象网项立刚 的微博,给力![good]</text>
      <source>
        <a href="http://t.sina.com.cn">新浪微博</a>
      </source>
      <favorited>false</favorited>
      <truncated>false</truncated>
      <geo/>
      <in_reply_to_status_id/>
      <in_reply_to_user_id/>
      <in_reply_to_screen_name/>
      <retweeted_status>
        <created_at>Fri Dec 03 13:45:02 +0800 2010</created_at>
        <id>4051797049</id>
        <text>#3G创新应用#工信部电信研究院通信信息所所长徐玉正在演讲,数据很详实,人也很漂亮。</text>
        <source>
          <a href="http://t.sina.com.cn/mobile/msg.php">彩信</a>
        </source>
        <favorited>false</favorited>
        <truncated>false</truncated>
        <geo/>
        <in_reply_to_status_id/>
        <in_reply_to_user_id/>
        <in_reply_to_screen_name/>
        <thumbnail_pic>http://ww3.sinaimg.cn/thumbnail/4c1526eajw6dbzdl54fmoj.jpg</thumbnail_pic>
        <bmiddle_pic>http://ww3.sinaimg.cn/bmiddle/4c1526eajw6dbzdl54fmoj.jpg</bmiddle_pic>
        <original_pic>http://ww3.sinaimg.cn/large/4c1526eajw6dbzdl54fmoj.jpg</original_pic>
        <user>
          <id>1276454634</id>
          <screen_name>孙慧飞象</screen_name>
          <name>孙慧飞象</name>
          <province>11</province>
          <city>5</city>
          <location>北京 朝阳区</location>
          <description>远树两行山倒影,轻舟一叶水平流</description>
          <url>http://blog.sina.com.cn/sunhuiblog</url>
          <profile_image_url>http://tp3.sinaimg.cn/1276454634/50/1283155247/0</profile_image_url>
          <domain>sunhui123</domain>
          <gender>f</gender>
          <followers_count>871</followers_count>
          <friends_count>314</friends_count>
          <statuses_count>552</statuses_count>
          <favourites_count>4</favourites_count>
          <created_at>Fri Oct 16 00:00:00 +0800 2009</created_at>
          <following>false</following>
          <verified>true</verified>
          <allow_all_act_msg>true</allow_all_act_msg>
          <geo_enabled>true</geo_enabled>
        </user>
        <annotations/>
      </retweeted_status>
      <annotations/>
    </status>
  </user>
  ...
  <next_cursor>1</next_cursor>
  <previous_cursor>0</previous_cursor>
</users>

JSON Example

{
    "users" : 
    [
        {
            "name" : "周立清",
            "domain" : "xyzlinger",
            "geo_enabled" : true,
            "followers_count" : 4652,
            "statuses_count" : 3897,
            "favourites_count" : 5,
            "city" : "1",
            "description" : "新浪微博开放平台(open.t.sina.com.cn),欢迎广大站长朋友前来聊聊:13718188488 、 010-62676120 、QQ:3653550、liqing3@staff.sina.com.cn",
            "verified" : true,
            "remark" : "",
            "status" : 
            {
                "created_at" : "Fri Dec 03 13:49:07 +0800 2010",
                "text" : "哈哈,看到新浪@微博大屏幕 了[哈哈],第一条是@飞象网项立刚 的微博,给力![good]",
                "truncated" : false,
                "retweeted_status" : 
                {
                    "created_at" : "Fri Dec 03 13:45:02 +0800 2010",
                    "text" : "#3G创新应用#工信部电信研究院通信信息所所长徐玉正在演讲,数据很详实,人也很漂亮。",
                    "bmiddle_pic" : "http://ww3.sinaimg.cn/bmiddle/4c1526eajw6dbzdl54fmoj.jpg",
                    "original_pic" : "http://ww3.sinaimg.cn/large/4c1526eajw6dbzdl54fmoj.jpg",
                    "truncated" : false,
                    "in_reply_to_status_id" : "",
                    "annotations" : 
                    [

                    ],
                    "in_reply_to_screen_name" : "",
                    "geo" : null,
                    "user" : 
                    {
                        "name" : "孙慧飞象",
                        "domain" : "sunhui123",
                        "geo_enabled" : true,
                        "followers_count" : 871,
                        "statuses_count" : 552,
                        "favourites_count" : 4,
                        "city" : "5",
                        "description" : "远树两行山倒影,轻舟一叶水平流",
                        "verified" : true,
                        "id" : 1276454634,
                        "gender" : "f",
                        "friends_count" : 314,
                        "screen_name" : "孙慧飞象",
                        "allow_all_act_msg" : true,
                        "following" : false,
                        "url" : "http://blog.sina.com.cn/sunhuiblog",
                        "profile_image_url" : "http://tp3.sinaimg.cn/1276454634/50/1283155247/0",
                        "created_at" : "Fri Oct 16 00:00:00 +0800 2009",
                        "province" : "11",
                        "location" : "北京 朝阳区"
                    },
                    "favorited" : false,
                    "thumbnail_pic" : "http://ww3.sinaimg.cn/thumbnail/4c1526eajw6dbzdl54fmoj.jpg",
                    "in_reply_to_user_id" : "",
                    "id" : 4051797049,
                    "source" : "<a href=\"http://t.sina.com.cn/mobile/msg.php\" rel=\"nofollow\">彩信</a>"
                },
                "in_reply_to_status_id" : "",
                "annotations" : 
                [

                ],
                "in_reply_to_screen_name" : "",
                "geo" : null,
                "favorited" : false,
                "in_reply_to_user_id" : "",
                "id" : 4051881415,
                "source" : "<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>"
            },
            "id" : 1473612611,
            "gender" : "m",
            "friends_count" : 1060,
            "screen_name" : "周立清",
            "allow_all_act_msg" : true,
            "following" : false,
            "url" : "http://www.linger.cn",
            "profile_image_url" : "http://tp4.sinaimg.cn/1473612611/50/1284048157/1",
            "created_at" : "Fri Aug 28 00:00:00 +0800 2009",
            "province" : "14",
            "location" : "山西 太原"
        },
        ...
    ],
    "next_cursor" : 1,
    "previous_cursor" : 0
}

Field Description - user

  • id: User ID
  • screen_name: User’s nickname displayed on the home page
  • name: Friendly displayed name, the same as screen_name
  • province: Province code ( see Province and city code table)
  • city: City code ( see Province and city code table)
  • location:Address
  • description: Personal description
  • url: Url of the user’s blog
  • profile_image_url: Profile image
  • domain: The user’s personalized weibo url
  • gender: Gender, m—male, f- - female, n-- unknown
  • followers_count: Followers count
  • friends_count: Following count
  • statuses_count: Weibo count
  • favourites_count: Favorites count
  • created_at: Created time
  • following: Whether the current user is following the user that posts the weibo (Not supported yet)
  • verified: Whether the user is verified by his real identity, marked with “V”

Field Description - weibo

  • created_at: Create time
  • id: Weibo ID
  • text: Weibo content
  • source: Weibo source
  • favorited: Whether it is favroited
  • truncated: Whether it is truncated
  • in_reply_to_status_id: The reply’s ID
  • in_reply_to_user_id: UID of the replyer
  • in_reply_to_screen_name: Nickname of replyer
  • thumbnail_pic: Thumbnail picture
  • bmiddle_pic: Medium picture
  • original_pic:Original picture
  • user: User profile
  • retweeted_status: eposted weibo content, the content is the status, This filed is only available for a reposted weibo.

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.Weibo;
import weibo4j.User;

public class GetFriends {

	    /**
	     * Usage: java -DWeibo4j.oauth.consumerKey=[consumer key] -DWeibo4j.oauth.consumerSecret=
		 [consumer secret] Weibo4j.examples.GetFriends [accessToken] [accessSecret]
	     * @param args message
	     */
	    public static void main(String[] args) {
	        try {
	        	System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
	        	System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);
	        	
	            Weibo weibo = new Weibo();
	            
	            weibo.setToken(args[0], args[1]);
	  
				 try {
					List<User> list= weibo.getFriendsStatuses();	
					System.out.println("Successfully get Friends to [" + list + "].");
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
	            System.exit(0);
	        } catch (Exception ioe) {
	            System.out.println("Failed to read the system input.");
	            System.exit( -1);
	        }
	    }
}

PHP Example

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

//Statuses/friends
$c = new WeiboClient( WB_AKEY , 
                      WB_SKEY , 
                      $_SESSION['last_key']['oauth_token'] , 
                      $_SESSION['last_key']['oauth_token_secret']  );
//用户ID
$u_id = "User_ID";
$msg = $c->friends(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 $friend){
	echo($friend['id'].' : '.$friend['name'].'  '.$friend['created_at'].' ;');
}



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