Statuses/comments/en

跳转到: 导航, 搜索

目录

statuses/comments

Return the comment list of a weibo by its ID.

URL

http://api.t.sina.com.cn/statuses/comments.(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 true int64 Specify the weibo ID to get its comment list.
count false int, default is 20, max is 200. Specify the number of weibos return for each page.
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 weibos.

Notes

Example Request

XML
curl -u "username:password" "http://api.t.sina.com.cn/statuses/comments.xml?source=appkey&id=1&count=2"
JSON
curl -u "username:password" "http://api.t.sina.com.cn/statuses/comments.json?source=appkey&id=1&count=2"

Response

XML Example

<?xml version="1.0" encoding="UTF-8"?>
<comments>
  <comment>
    <created_at>Sat Nov 13 15:57:53 +0800 2010</created_at>
    <id>4476725917</id>
    <text> help</text>
    <user>
      <id>1611511443</id>
      <screen_name>无冷afcold</screen_name>
      <name>无冷afcold</name>
      <province>51</province>
      <city>1</city>
      <location>四川 成都</location>
      <description/>
      <url>http://blog.sina.com.cn/sureceive</url>
      <profile_image_url>http://tp4.sinaimg.cn/1611511443/50/1290602543/1</profile_image_url>
      <domain>atpal</domain>
      <gender>m</gender>
      <followers_count>18</followers_count>
      <friends_count>21</friends_count>
      <statuses_count>69</statuses_count>
      <favourites_count>1</favourites_count>
      <created_at>Tue Oct 20 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>Sun Nov 28 12:50:17 +0800 2010</created_at>
        <id>3933955277</id>
        <text>我刚加入了“ubuntu军团”微群 http://sinaurl.cn/hbAfsD 推荐大家也来看看~</text>
        <source>
          <a href="http://group.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/>
      </status>
    </user>
    <status>
      <created_at>Thu Mar 18 19:07:05 +0800 2010</created_at>
      <id>1</id>
      <text>这么小就入党了 敬仰~</text>
      <source>
        <a href="http://news.sina.com.cn/wap/wbk.html/">新浪微博手机版</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>1152759471</id>
        <screen_name>老王</screen_name>
        <name>老王</name>
        <province>11</province>
        <city>8</city>
        <location>北京 海淀区</location>
        <description>哼。。。 花样真多。 讨厌。</description>
        <url>http://1</url>
        <profile_image_url>http://tp4.sinaimg.cn/1152759471/50/1263371934</profile_image_url>
        <domain>hotpixel</domain>
        <gender>m</gender>
        <followers_count>1567</followers_count>
        <friends_count>202</friends_count>
        <statuses_count>6776</statuses_count>
        <favourites_count>0</favourites_count>
        <created_at>Fri Aug 28 00:00:00 +0800 2009</created_at>
        <following>false</following>
        <verified>false</verified>
        <allow_all_act_msg>false</allow_all_act_msg>
        <geo_enabled>false</geo_enabled>
      </user>
      <retweeted_status>
        <created_at>Thu Mar 18 19:05:52 +0800 2010</created_at>
        <id>27657268</id>
        <text>班里开始交团费了,跟我没关系</text>
        <source>
          <a href="http://news.sina.com.cn/wap/wbk.html/">新浪微博手机版</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>1654703984</id>
          <screen_name>高考铅笔亚克西</screen_name>
          <name>高考铅笔亚克西</name>
          <province>42</province>
          <city>1</city>
          <location>湖北 武汉</location>
          <description>在通往高考的路上乳摇狂奔,偶尔发骚回头抛个媚眼骂句操蛋,切不可以为姐就是招之即上挥之自摸的小娘儿们。好不容易成年了,姐要更加有湿想嗯哼。</description>
          <url/>
          <profile_image_url>http://tp1.sinaimg.cn/1654703984/50/1264140632</profile_image_url>
          <domain>kimmy14</domain>
          <gender>f</gender>
          <followers_count>1330</followers_count>
          <friends_count>755</friends_count>
          <statuses_count>3354</statuses_count>
          <favourites_count>0</favourites_count>
          <created_at>Mon Oct 19 00:00:00 +0800 2009</created_at>
          <following>false</following>
          <verified>false</verified>
          <allow_all_act_msg>false</allow_all_act_msg>
          <geo_enabled>false</geo_enabled>
        </user>
      </retweeted_status>
    </status>
  </comment>
...
</comments>

JSON Example

[
    {
        "id" : 2794158817,
        "text" : "军训多久?",
        "created_at" : "Fri Sep 03 12:07:14 +0800 2010",
        "user" : 
        {
            "name" : "乖乖的仲夏夜之梦",
            "domain" : "",
            "geo_enabled" : true,
            "followers_count" : 12,
            "statuses_count" : 42,
            "favourites_count" : 2,
            "city" : "13",
            "description" : "",
            "verified" : false,
            "status" : 
            {
                "created_at" : "Wed Dec 01 09:50:24 +0800 2010",
                "text" : "//@优酷网:#优酷分享#周一早上听听16岁小男孩活力的歌声,提提神。开始战斗!",
                "truncated" : false,
                "retweeted_status" : 
                {
                    "created_at" : "Mon Nov 29 08:58:52 +0800 2010",
                    "text" : "【猴姆独家】超震撼!Justin Bieber做客英国偶像激情串烧Somebody To Love和Baby高清完整现场 http://sinaurl.cn/hbyEw3  via@优酷网",
                    "truncated" : false,
                    "in_reply_to_status_id" : "",
                    "in_reply_to_screen_name" : "",
                    "geo" : null,
                    "user" : 
                    {
                        "name" : "Houson猴姆",
                        "domain" : "houson100037",
                        "geo_enabled" : true,
                        "followers_count" : 14840,
                        "statuses_count" : 1496,
                        "favourites_count" : 0,
                        "city" : "10",
                        "description" : "",
                        "verified" : false,
                        "id" : 1258256457,
                        "gender" : "m",
                        "friends_count" : 37,
                        "screen_name" : "Houson猴姆",
                        "allow_all_act_msg" : true,
                        "following" : false,
                        "url" : "http://blog.sina.com.cn/houson100037",
                        "profile_image_url" : "http://tp2.sinaimg.cn/1258256457/50/1283203847/1",
                        "created_at" : "Wed May 19 00:00:00 +0800 2010",
                        "province" : "37",
                        "location" : "山东 威海"
                    },
                    "favorited" : false,
                    "in_reply_to_user_id" : "",
                    "id" : 3950816793,
                    "source" : "<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>"
                },
                "in_reply_to_status_id" : "",
                "in_reply_to_screen_name" : "",
                "geo" : null,
                "favorited" : false,
                "in_reply_to_user_id" : "",
                "id" : 3994851987,
                "source" : "<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>"
            },
            "id" : 1785964704,
            "gender" : "f",
            "friends_count" : 58,
            "screen_name" : "乖乖的仲夏夜之梦",
            "allow_all_act_msg" : false,
            "following" : false,
            "url" : "",
            "profile_image_url" : "http://tp1.sinaimg.cn/1785964704/50/0",
            "created_at" : "Wed Aug 04 00:00:00 +0800 2010",
            "province" : "43",
            "location" : "湖南 娄底"
        },
        "status" : 
        {
            "created_at" : "Fri Sep 03 11:41:08 +0800 2010",
            "text" : "今日下午回初中看看,然后老同学请吃饭,因为距明天就去报到了,最后的晚餐。希望老天留翻D眼泪等到我军训时先留。。",
            "truncated" : false,
            "in_reply_to_status_id" : "",
            "in_reply_to_screen_name" : "",
            "geo" : null,
            "user" : 
            {
                "name" : "标-心",
                "domain" : "",
                "geo_enabled" : true,
                "followers_count" : 37,
                "statuses_count" : 282,
                "favourites_count" : 0,
                "city" : "1",
                "description" : "见仁见智",
                "verified" : false,
                "id" : 1763124584,
                "gender" : "m",
                "friends_count" : 41,
                "screen_name" : "标-心",
                "allow_all_act_msg" : true,
                "following" : false,
                "url" : "http://blog.163.com/chen_mou/",
                "profile_image_url" : "http://tp1.sinaimg.cn/1763124584/50/1283605697/1",
                "created_at" : "Thu Jun 17 00:00:00 +0800 2010",
                "province" : "44",
                "location" : "广东 广州"
            },
            "favorited" : false,
            "in_reply_to_user_id" : "",
            "id" : 2265657555,
            "source" : "<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>"
        }
    },
...
]

Field Description - comment

  • id: Comment ID
  • text: Comment content
  • source: Comment source
  • favorited: Whether it is favorited
  • truncated: Whether it is truncated
  • created_at: Created time
  • user: User profile that posts the comment.
  • status: The weibo that is commented
  • reply_comment Comment source. Has a same data structure as comment.

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:

 public class GetCommentsOfStatus {
 
 	/**
 	 * 获取某条微博消息的评论列表
 	 * @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(true,args);
         	//args[2]:用户id
         	List<Status> list = weibo.getUserTimeline(args[2]);
        	if(list.size() > 0) {
         		//最新一条微博信息id
         		String sid = list.get(0).getId()+"";
        		//对该微博消息添加评论
         		weibo.updateComment("测试评论", sid , null);
        		
        		weibo.getComments(sid);
        	}
 	    } catch (Exception 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/comments_by_me
$c = new WeiboClient( WB_AKEY , 
                      WB_SKEY , 
                      $_SESSION['last_key']['oauth_token'] , 
                      $_SESSION['last_key']['oauth_token_secret']  );
$msg  = $c->comments_by_me();
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.";";
}



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