Statuses/comment

跳转到: 导航, 搜索
(返回)
 
(未显示6个用户的27个中间版本)
第1行: 第1行:
== statuses/comment ==
+
{{api_desc2|
对一条微博信息进行评论。请求必须用POST方式提交。为防止重复,发布的信息与最后一条评论信息一样话,将会被忽略。
+
uri=statuses/comment|
 
+
desc=对一条微博信息进行评论。请求必须用POST方式提交。|
=== URL===
+
format=XML/JSON|
curl http://api.t.sina.com.cn/statuses/comment.format
+
httpMethod=POST|
+
needAuth=true|
=== 格式===
+
rateLimit=true|
xml, json, rss, atom
+
params={{api_args|id|true|int64|要评论的微博消息ID}}
+
{{api_args|comment|true|string|评论内容。必须做URLEncode,信息内容不超过140个汉字。}}
=== HTTP请求方式===
+
{{api_args|cid|false|int64|要回复的评论ID。}}
POST
+
{{api_args|without_mention|false|int|1:回复中不自动加入“回复@用户名”,0:回复中自动加入“回复@用户名”.默认为0.}}
+
{{api_args|comment_ori|false|int|当评论一条转发微博时,是否评论给原微博。0:不评论给原微博。1:评论给原微博。默认0.}}|
=== 是否需要身份验证===
+
getParam=|
true
+
postParam=-d "id=4046214423&comment=wahaha"|
+
result=
=== 请求数限制===
+
===XML示例===
false
+
<pre>
 
+
<?xml version="1.0" encoding="UTF-8"?>
=== 请求参数===
+
<comment>
* id 必填参数, 要评论的微博id
+
  <created_at>Fri Dec 03 10:22:44 +0800 2010</created_at>
* cid 选填参数, 要评论的评论id
+
  <id>4976730453</id>
* comment.  必填参数, 评论内容。必须做URLEncode,信息内容不超过140个汉字。
+
  <text>wahaha</text>
 
+
  <source>
=== 使用说明===
+
    <a href="http://open.t.sina.com.cn">微博开放平台接口</a>
* 如果没有登录或超过发布上限,将返回403错误
+
  </source>
* 系统将忽略重复发布的评论信息。每次发布将比较最后一条发布评论消息,如果一样将被忽略。因此用户不能连续提交相同信息。发布成功返回发布的信息ID,否则返回为空。
+
  <user>
 
+
    <id>1658122963</id>
=== 返回 ===
+
    <screen_name>zhangwei217245</screen_name>
XML示例:
+
    <name>zhangwei217245</name>
<?xml version="1.0" encoding="UTF-8"?>
+
    <province>11</province>
<comment>
+
    <city>5</city>
    <created_at>Mon Dec 28 10:39:24 +0800 2009</created_at>
+
    <location>北京 朝阳区</location>
    <id>40406</id>(评论ID)
+
    <description>ABCDE</description>
    <text>abcdef</text>
+
    <url/>
    <source>
+
    <profile_image_url>http://tp4.sinaimg.cn/1658122963/50/1282754213</profile_image_url>
      <a id="0" href="http://t.sina.com.cn">Web</a>
+
    <domain>zhangwei217245</domain>
    </source>
+
    <gender>m</gender>
    <user>
+
    <followers_count>22</followers_count>
      <id>11075</id>
+
    <friends_count>43</friends_count>
      <screen_name>name_11075</screen_name>
+
    <statuses_count>115</statuses_count>
      <name>name_11075</name>
+
    <favourites_count>3</favourites_count>
      <province></province>
+
    <created_at>Tue Nov 03 00:00:00 +0800 2009</created_at>
      <city></city>
+
    <following>false</following>
      <location></location>
+
    <verified>false</verified>
      <description></description>
+
    <allow_all_act_msg>false</allow_all_act_msg>
      <profile_image_url>http://tp4.sinaimg.cn/11075/50/0</profile_image_url>
+
     <geo_enabled>true</geo_enabled>
      <domain>11075</domain>
+
      <gender></gender>
+
      <email></email>
+
      <qq>1817</qq>
+
      <msn>msn_1817</msn>
+
      <followers_count>22</followers_count>
+
      <friends_count>30</friends_count>
+
      <statuses_count>0</statuses_count>
+
      <favourites_count>0</favourites_count>
+
      <created_at>Thu Jan 01 08:00:00 +0800 1970</created_at>
+
      <following>false</following>
+
      <verified>false</verified>
+
      <geo_enabled>false</geo_enabled>
+
     </user>
+
 
     <status>
 
     <status>
       <created_at>Mon Dec 28 10:37:59 +0800 2009</created_at>
+
       <created_at>Thu Dec 02 17:23:52 +0800 2010</created_at>
       <id>19105</id>
+
       <id>4023418959</id>
       <text>测试中国</text>
+
       <text>哎呀妈呀,终于找到组织了。</text>
 
       <source>
 
       <source>
         <a id="0" href="http://t.sina.com.cn">Web</a>
+
         <a href="http://t.sina.com.cn">新浪微博</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/>
      <user>
+
       <retweeted_status>
        <id>11075</id>
+
        <created_at>Thu Dec 02 17:23:03 +0800 2010</created_at>
        <screen_name>name_11075</screen_name>
+
        <id>4023402439</id>
        <name>name_11075</name>
+
        <text>再看看在哪AGAIN</text>
        <province></province>
+
        <source>
        <city></city>
+
          <a href="">微博开放平台接口</a>
        <location></location>
+
        </source>
        <description></description>
+
        <favorited>false</favorited>
        <profile_image_url>http://tp4.sinaimg.cn/11075/50/0</profile_image_url>
+
        <truncated>false</truncated>
        <domain>11075</domain>
+
        <geo xmlns:georss="http://www.georss.org/georss">
        <gender></gender>
+
          <georss:point>39.984833 116.310005</georss:point>
        <email></email>
+
        </geo>
        <qq>1817</qq>
+
        <in_reply_to_status_id/>
        <msn>msn_1817</msn>
+
        <in_reply_to_user_id/>
        <followers_count>22</followers_count>
+
        <in_reply_to_screen_name/>
        <friends_count>30</friends_count>
+
        <user>
        <statuses_count>0</statuses_count>
+
          <id>1658122963</id>
        <favourites_count>0</favourites_count>
+
          <screen_name>zhangwei217245</screen_name>
        <created_at>Thu Jan 01 08:00:00 +0800 1970</created_at>
+
          <name>zhangwei217245</name>
        <following>false</following>
+
          <province>11</province>
        <verified>false</verified>
+
          <city>5</city>
        <geo_enabled>false</geo_enabled>
+
          <location>北京 朝阳区</location>
      </user>
+
          <description>ABCDE</description>
 +
          <url/>
 +
          <profile_image_url>http://tp4.sinaimg.cn/1658122963/50/1282754213</profile_image_url>
 +
          <domain>zhangwei217245</domain>
 +
          <gender>m</gender>
 +
          <followers_count>22</followers_count>
 +
          <friends_count>43</friends_count>
 +
          <statuses_count>113</statuses_count>
 +
          <favourites_count>3</favourites_count>
 +
          <created_at>Tue Nov 03 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>
 +
        </user>
 +
      </retweeted_status>
 +
      <annotations/>
 
     </status>
 
     </status>
   </comment>
+
   </user>
 +
  <status>
 +
    <created_at>Fri Dec 03 09:25:51 +0800 2010</created_at>
 +
    <id>4046214423</id>
 +
    <text>维基解密新主机被曝位于军事掩体内(图) http://sinaurl.cn/hbqEya</text>
 +
    <source>
 +
      <a href="http://tech.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/>
 +
    <thumbnail_pic>http://ww3.sinaimg.cn/thumbnail/63743d1cjw6dbz63h1rfrj.jpg</thumbnail_pic>
 +
    <bmiddle_pic>http://ww3.sinaimg.cn/bmiddle/63743d1cjw6dbz63h1rfrj.jpg</bmiddle_pic>
 +
    <original_pic>http://ww3.sinaimg.cn/large/63743d1cjw6dbz63h1rfrj.jpg</original_pic>
 +
    <user>
 +
      <id>1668562204</id>
 +
      <screen_name>赵海俊的微薄</screen_name>
 +
      <name>赵海俊的微薄</name>
 +
      <province>11</province>
 +
      <city>5</city>
 +
      <location>北京 朝阳区</location>
 +
      <description>运动健将</description>
 +
      <url>http://blog.sina.com.cn/eshesoulheart</url>
 +
      <profile_image_url>http://tp1.sinaimg.cn/1668562204/50/1279885528/1</profile_image_url>
 +
      <domain/>
 +
      <gender>m</gender>
 +
      <followers_count>315</followers_count>
 +
      <friends_count>611</friends_count>
 +
      <statuses_count>2984</statuses_count>
 +
      <favourites_count>53</favourites_count>
 +
      <created_at>Thu Dec 10 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>
 +
    </user>
 +
    <annotations/>
 +
  </status>
 +
</comment>
 +
</pre>
 +
===JSON示例===
 +
<pre>
 +
{
 +
    "id" : 4976882559,
 +
    "text" : "wakaka",
 +
    "created_at" : "Fri Dec 03 10:28:55 +0800 2010",
 +
    "source" : "<a href=\"http://open.t.sina.com.cn\" rel=\"nofollow\">微博开放平台接口</a>",
 +
    "user" :
 +
    {
 +
        "name" : "zhangwei217245",
 +
        "domain" : "zhangwei217245",
 +
        "geo_enabled" : true,
 +
        "followers_count" : 22,
 +
        "statuses_count" : 115,
 +
        "favourites_count" : 3,
 +
        "city" : "5",
 +
        "description" : "ABCDE",
 +
        "verified" : false,
 +
        "status" :
 +
        {
 +
            "created_at" : "Thu Dec 02 17:23:52 +0800 2010",
 +
            "text" : "哎呀妈呀,终于找到组织了。",
 +
            "truncated" : false,
 +
            "retweeted_status" :
 +
            {
 +
                "created_at" : "Thu Dec 02 17:23:03 +0800 2010",
 +
                "text" : "再看看在哪AGAIN",
 +
                "truncated" : false,
 +
                "in_reply_to_status_id" : "",
 +
                "in_reply_to_screen_name" : "",
 +
                "geo" :
 +
                {
 +
                    "type" : "Point",
 +
                    "coordinates" :
 +
                    [
 +
                        39.984833,
 +
                        116.310005
 +
                    ]
 +
                },
 +
                "user" :
 +
                {
 +
                    "name" : "zhangwei217245",
 +
                    "domain" : "zhangwei217245",
 +
                    "geo_enabled" : true,
 +
                    "followers_count" : 22,
 +
                    "statuses_count" : 113,
 +
                    "favourites_count" : 3,
 +
                    "city" : "5",
 +
                    "description" : "ABCDE",
 +
                    "verified" : false,
 +
                    "id" : 1658122963,
 +
                    "gender" : "m",
 +
                    "friends_count" : 43,
 +
                    "screen_name" : "zhangwei217245",
 +
                    "allow_all_act_msg" : false,
 +
                    "following" : false,
 +
                    "url" : "",
 +
                    "profile_image_url" : "http://tp4.sinaimg.cn/1658122963/50/1282754213",
 +
                    "created_at" : "Tue Nov 03 00:00:00 +0800 2009",
 +
                    "province" : "11",
 +
                    "location" : "北京 朝阳区"
 +
                },
 +
                "favorited" : false,
 +
                "in_reply_to_user_id" : "",
 +
                "id" : 4023402439,
 +
                "source" : "<a href=\"\" rel=\"nofollow\">微博开放平台接口</a>"
 +
            },
 +
            "in_reply_to_status_id" : "",
 +
            "annotations" :
 +
            [
  
JSON:示例
+
            ],
 +
            "in_reply_to_screen_name" : "",
 +
            "geo" : null,
 +
            "favorited" : false,
 +
            "in_reply_to_user_id" : "",
 +
            "id" : 4023418959,
 +
            "source" : "<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>"
 +
        },
 +
        "id" : 1658122963,
 +
        "gender" : "m",
 +
        "friends_count" : 43,
 +
        "screen_name" : "zhangwei217245",
 +
        "allow_all_act_msg" : false,
 +
        "following" : false,
 +
        "url" : "",
 +
        "profile_image_url" : "http://tp4.sinaimg.cn/1658122963/50/1282754213",
 +
        "created_at" : "Tue Nov 03 00:00:00 +0800 2009",
 +
        "province" : "11",
 +
        "location" : "北京 朝阳区"
 +
    },
 +
    "status" :
 +
    {
 +
        "created_at" : "Fri Dec 03 09:25:51 +0800 2010",
 +
        "text" : "维基解密新主机被曝位于军事掩体内(图) http://sinaurl.cn/hbqEya",
 +
        "bmiddle_pic" : "http://ww3.sinaimg.cn/bmiddle/63743d1cjw6dbz63h1rfrj.jpg",
 +
        "original_pic" : "http://ww3.sinaimg.cn/large/63743d1cjw6dbz63h1rfrj.jpg",
 +
        "truncated" : false,
 +
        "in_reply_to_status_id" : "",
 +
        "annotations" :
 +
        [
  
    {"created_at":"Thu Jan 07 09:00:32 +0800 2010",
+
        ],
    "id":203065,
+
        "in_reply_to_screen_name" : "",
    "text":"commenttest",
+
        "geo" : null,
    "source":"<a id=\"0\" href=\"http://t.sina.com.cn/\" rel=\"nofollow\">Web</a>",
+
        "user" :  
    "user":<br/>      {"id":11051,
+
        {
      "screen_name":"name_11051",
+
            "name" : "赵海俊的微薄",
      "name":"name_11051",
+
            "domain" : "",
      "province":"0",
+
            "geo_enabled" : true,
      "city":"0",
+
            "followers_count" : 315,
      "location":"",
+
            "statuses_count" : 2984,
      "description":"",
+
            "favourites_count" : 53,
      "profile_image_url":"http://tp4.sinaimg.cn/11051/50/0",
+
            "city" : "5",
      "domain":"11051",
+
            "description" : "运动健将",
      "email":"",
+
            "verified" : false,
      "qq":"305",
+
            "id" : 1668562204,
      "msn":"msn_305",
+
            "gender" : "m",
      "followers_count":27,
+
            "friends_count" : 611,
      "friends_count":60,
+
            "screen_name" : "赵海俊的微薄",
      "statuses_count":0,
+
            "allow_all_act_msg" : false,
      "favourites_count":1,
+
            "following" : false,
      "created_at":"Thu Jan 01 08:00:00 +0800 1970",
+
            "url" : "http://blog.sina.com.cn/eshesoulheart",
      "following":false,
+
            "profile_image_url" : "http://tp1.sinaimg.cn/1668562204/50/1279885528/1",
      "geo_enabled":false,
+
            "created_at" : "Thu Dec 10 00:00:00 +0800 2009",
      "verified":true,
+
            "province" : "11",
      "status":<br/>         {"created_at":"Wed Jan 06 11:36:30 +0800 2010",
+
            "location" : "北京 朝阳区"
          "id":142246,
+
        },
          "text":"凤飞飞",
+
        "favorited" : false,
          "source":"<a id=\"0\" href=\"http://t.sina.com.cn/\" rel=\"nofollow\">Web</a>",
+
         "thumbnail_pic" : "http://ww3.sinaimg.cn/thumbnail/63743d1cjw6dbz63h1rfrj.jpg",
          "favorited":false,
+
        "in_reply_to_user_id" : "",
          "truncated":false,
+
        "id" : 4046214423,
          "in_reply_to_status_id":"",
+
        "source" : "<a href=\"http://tech.sina.com.cn/\" rel=\"nofollow\">新浪科技</a>"
          "in_reply_to_user_id":"",
+
    }
          "in_reply_to_screen_name":"",
+
}
          "geo":null,
+
</pre>|
          "apiState":3}<br/>   },
+
useAge=
    "status":<br/>      {"created_at":"Wed Jan 06 19:02:40 +0800 2010",
+
* 1. 为防止重复提交,发表的评论与上次发表的评论内容相同的时候,将返回400错误。
      "id":142277,
+
* 2. 如果id及cid不存在,将返回400错误
      "text":"111111111111111111111",
+
* 3. 如果提供了正确的cid参数,则该接口的表现为回复指定的评论。此时id参数将被忽略。即使cid参数代表的评论不属于id参数代表的微博消息,通过该接口发表的评论信息直接回复cid代表的评论。回复评论的返回结果参见[[statuses/reply]]
      "source":"<a id=\"0\" href=\"http://t.sina.com.cn/\" rel=\"nofollow\">Web</a>",
+
*4. 同时评论给原微博时,全部评论成功才返回成功,否则返回相应出错信息。|
      "favorited":false,
+
otherInfo=
      "truncated":false,
+
===Java示例===
      "in_reply_to_status_id":"",
+
请从 [[SDK | 微博SDK开发包下载]] 下载Java SDK<br>
      "in_reply_to_user_id":"",
+
代码示例如下:
      "in_reply_to_screen_name":"",
+
package weibo4j.examples;
      "geo":null,
+
      "user":<br/>              {"id":11057,
+
import weibo4j.Status;
                "screen_name":"name_11057",
+
import weibo4j.Weibo;
                "name":"name_11057",
+
                "province":"0",
+
public class UpdateComment {
                "city":"0",
+
                "location":"",
+
/**
                "description":"",
+
* 对一条微博信息进行评论
                "profile_image_url":"http://tp2.sinaimg.cn/11057/50/0",
+
* @param args
                "domain":"11057",
+
*/
                "email":"",
+
public static void main(String[] args) {
                "qq":"8990",
+
System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
                "msn":"msn_8990",
+
    System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);
                "followers_count":19,
+
        try {
                "friends_count":101,
+
        Weibo weibo = getWeibo(true,args);
                "statuses_count":0,
+
        Status status = weibo.updateStatus("测试12345");//发表新微博信息
                "favourites_count":0,
+
        Thread.sleep(1000);
                "created_at":"Thu Jan 01 08:00:00 +0800 1970",
+
        String sid = status.getId()+"";//微博id
                "following":false,
+
        System.out.println(sid + " : "+ status.getText()+" "+status.getCreatedAt());
                "geo_enabled":false,
+
        weibo.updateComment("测试评论", sid, null);//对刚发表的微博进行评论
                "verified":false},
+
        Comment comment = weibo.updateComment("测试评论", sid, null);
      "apiState":3},
+
        System.out.println(comment.getId() + " : " + comment.getText() + " " + comment.getCreatedAt());
    "apiState":3}
+
} catch (Exception e) {
 
+
e.printStackTrace();
=== 使用示例===
+
}
cURL:
+
}
 
+
XML:
+
private static Weibo getWeibo(boolean isOauth,String ... args) {
 
+
Weibo weibo = new Weibo();
curl -u user:password -d "id=12345&status=playing with cURL and the Sina API" http://api.t.sina.com.cn/statuses/comment.xml
+
if(isOauth) {//oauth验证方式 args[0]:访问的token;args[1]:访问的密匙
 
+
weibo.setToken(args[0], args[1]);
JSON:
+
}else {//用户登录方式
 
+
    weibo.setUserId(args[0]);//用户名/ID
curl -u user:password -d "id=12345&status=playing with cURL and the Sina API" http://api.t.sina.com.cn/statuses/comment.json
+
      weibo.setPassword(args[1]);//密码
 +
}
 +
return weibo;
 +
}
 +
}
 +
===PHP示例===
 +
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br>
 +
代码示例如下:
 +
<pre>
 +
//Statuses/comment
 +
// 对一条微博信息进行评论
 +
$c = new WeiboClient( WB_AKEY ,  
 +
                      WB_SKEY ,  
 +
                      $_SESSION['last_key']['oauth_token'] ,  
 +
                      $_SESSION['last_key']['oauth_token_secret']  );
 +
//发表新微博信息
 +
$msg = $c->update("测试发表微博");
 +
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;
 +
}
 +
//微博id
 +
$sid = $msg['id'];
 +
echo($sid." : ".$msg['text']." ".$msg["created_at"]);
 +
sleep(5);
 +
//对刚发表的微博进行评论
 +
$msg = $c->send_comment($sid,"测试评论",null);
 +
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;
 +
}
 +
echo($msg['id'].' : '.$msg['text'].'  '.$msg['created_at']);
 +
</pre>
 +
}}

2012年9月24日 (一) 11:37的最后版本

目录

statuses/comment

对一条微博信息进行评论。请求必须用POST方式提交。

URL

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

支持格式

XML/JSON

HTTP请求方式

POST

是否需要登录

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

请求数限制

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

请求参数

  必选 类型及范围 说明
source true string 申请应用时分配的AppKey,调用接口时候代表应用的唯一身份。(采用OAuth授权方式不需要此参数)
id true int64 要评论的微博消息ID
comment true string 评论内容。必须做URLEncode,信息内容不超过140个汉字。
cid false int64 要回复的评论ID。
without_mention false int 1:回复中不自动加入“回复@用户名”,0:回复中自动加入“回复@用户名”.默认为0.
comment_ori false int 当评论一条转发微博时,是否评论给原微博。0:不评论给原微博。1:评论给原微博。默认0.

注意事项

  • 1. 为防止重复提交,发表的评论与上次发表的评论内容相同的时候,将返回400错误。
  • 2. 如果id及cid不存在,将返回400错误
  • 3. 如果提供了正确的cid参数,则该接口的表现为回复指定的评论。此时id参数将被忽略。即使cid参数代表的评论不属于id参数代表的微博消息,通过该接口发表的评论信息直接回复cid代表的评论。回复评论的返回结果参见statuses/reply
  • 4. 同时评论给原微博时,全部评论成功才返回成功,否则返回相应出错信息。

返回结果

XML示例

<?xml version="1.0" encoding="UTF-8"?>
<comment>
  <created_at>Fri Dec 03 10:22:44 +0800 2010</created_at>
  <id>4976730453</id>
  <text>wahaha</text>
  <source>
    <a href="http://open.t.sina.com.cn">微博开放平台接口</a>
  </source>
  <user>
    <id>1658122963</id>
    <screen_name>zhangwei217245</screen_name>
    <name>zhangwei217245</name>
    <province>11</province>
    <city>5</city>
    <location>北京 朝阳区</location>
    <description>ABCDE</description>
    <url/>
    <profile_image_url>http://tp4.sinaimg.cn/1658122963/50/1282754213</profile_image_url>
    <domain>zhangwei217245</domain>
    <gender>m</gender>
    <followers_count>22</followers_count>
    <friends_count>43</friends_count>
    <statuses_count>115</statuses_count>
    <favourites_count>3</favourites_count>
    <created_at>Tue Nov 03 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>Thu Dec 02 17:23:52 +0800 2010</created_at>
      <id>4023418959</id>
      <text>哎呀妈呀,终于找到组织了。</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>Thu Dec 02 17:23:03 +0800 2010</created_at>
        <id>4023402439</id>
        <text>再看看在哪AGAIN</text>
        <source>
          <a href="">微博开放平台接口</a>
        </source>
        <favorited>false</favorited>
        <truncated>false</truncated>
        <geo xmlns:georss="http://www.georss.org/georss">
          <georss:point>39.984833 116.310005</georss:point>
        </geo>
        <in_reply_to_status_id/>
        <in_reply_to_user_id/>
        <in_reply_to_screen_name/>
        <user>
          <id>1658122963</id>
          <screen_name>zhangwei217245</screen_name>
          <name>zhangwei217245</name>
          <province>11</province>
          <city>5</city>
          <location>北京 朝阳区</location>
          <description>ABCDE</description>
          <url/>
          <profile_image_url>http://tp4.sinaimg.cn/1658122963/50/1282754213</profile_image_url>
          <domain>zhangwei217245</domain>
          <gender>m</gender>
          <followers_count>22</followers_count>
          <friends_count>43</friends_count>
          <statuses_count>113</statuses_count>
          <favourites_count>3</favourites_count>
          <created_at>Tue Nov 03 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>
        </user>
      </retweeted_status>
      <annotations/>
    </status>
  </user>
  <status>
    <created_at>Fri Dec 03 09:25:51 +0800 2010</created_at>
    <id>4046214423</id>
    <text>维基解密新主机被曝位于军事掩体内(图) http://sinaurl.cn/hbqEya</text>
    <source>
      <a href="http://tech.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/>
    <thumbnail_pic>http://ww3.sinaimg.cn/thumbnail/63743d1cjw6dbz63h1rfrj.jpg</thumbnail_pic>
    <bmiddle_pic>http://ww3.sinaimg.cn/bmiddle/63743d1cjw6dbz63h1rfrj.jpg</bmiddle_pic>
    <original_pic>http://ww3.sinaimg.cn/large/63743d1cjw6dbz63h1rfrj.jpg</original_pic>
    <user>
      <id>1668562204</id>
      <screen_name>赵海俊的微薄</screen_name>
      <name>赵海俊的微薄</name>
      <province>11</province>
      <city>5</city>
      <location>北京 朝阳区</location>
      <description>运动健将</description>
      <url>http://blog.sina.com.cn/eshesoulheart</url>
      <profile_image_url>http://tp1.sinaimg.cn/1668562204/50/1279885528/1</profile_image_url>
      <domain/>
      <gender>m</gender>
      <followers_count>315</followers_count>
      <friends_count>611</friends_count>
      <statuses_count>2984</statuses_count>
      <favourites_count>53</favourites_count>
      <created_at>Thu Dec 10 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>
    </user>
    <annotations/>
  </status>
</comment>

JSON示例

{
    "id" : 4976882559,
    "text" : "wakaka",
    "created_at" : "Fri Dec 03 10:28:55 +0800 2010",
    "source" : "<a href=\"http://open.t.sina.com.cn\" rel=\"nofollow\">微博开放平台接口</a>",
    "user" : 
    {
        "name" : "zhangwei217245",
        "domain" : "zhangwei217245",
        "geo_enabled" : true,
        "followers_count" : 22,
        "statuses_count" : 115,
        "favourites_count" : 3,
        "city" : "5",
        "description" : "ABCDE",
        "verified" : false,
        "status" : 
        {
            "created_at" : "Thu Dec 02 17:23:52 +0800 2010",
            "text" : "哎呀妈呀,终于找到组织了。",
            "truncated" : false,
            "retweeted_status" : 
            {
                "created_at" : "Thu Dec 02 17:23:03 +0800 2010",
                "text" : "再看看在哪AGAIN",
                "truncated" : false,
                "in_reply_to_status_id" : "",
                "in_reply_to_screen_name" : "",
                "geo" : 
                {
                    "type" : "Point",
                    "coordinates" : 
                    [
                        39.984833,
                        116.310005
                    ]
                },
                "user" : 
                {
                    "name" : "zhangwei217245",
                    "domain" : "zhangwei217245",
                    "geo_enabled" : true,
                    "followers_count" : 22,
                    "statuses_count" : 113,
                    "favourites_count" : 3,
                    "city" : "5",
                    "description" : "ABCDE",
                    "verified" : false,
                    "id" : 1658122963,
                    "gender" : "m",
                    "friends_count" : 43,
                    "screen_name" : "zhangwei217245",
                    "allow_all_act_msg" : false,
                    "following" : false,
                    "url" : "",
                    "profile_image_url" : "http://tp4.sinaimg.cn/1658122963/50/1282754213",
                    "created_at" : "Tue Nov 03 00:00:00 +0800 2009",
                    "province" : "11",
                    "location" : "北京 朝阳区"
                },
                "favorited" : false,
                "in_reply_to_user_id" : "",
                "id" : 4023402439,
                "source" : "<a href=\"\" rel=\"nofollow\">微博开放平台接口</a>"
            },
            "in_reply_to_status_id" : "",
            "annotations" : 
            [

            ],
            "in_reply_to_screen_name" : "",
            "geo" : null,
            "favorited" : false,
            "in_reply_to_user_id" : "",
            "id" : 4023418959,
            "source" : "<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>"
        },
        "id" : 1658122963,
        "gender" : "m",
        "friends_count" : 43,
        "screen_name" : "zhangwei217245",
        "allow_all_act_msg" : false,
        "following" : false,
        "url" : "",
        "profile_image_url" : "http://tp4.sinaimg.cn/1658122963/50/1282754213",
        "created_at" : "Tue Nov 03 00:00:00 +0800 2009",
        "province" : "11",
        "location" : "北京 朝阳区"
    },
    "status" : 
    {
        "created_at" : "Fri Dec 03 09:25:51 +0800 2010",
        "text" : "维基解密新主机被曝位于军事掩体内(图) http://sinaurl.cn/hbqEya",
        "bmiddle_pic" : "http://ww3.sinaimg.cn/bmiddle/63743d1cjw6dbz63h1rfrj.jpg",
        "original_pic" : "http://ww3.sinaimg.cn/large/63743d1cjw6dbz63h1rfrj.jpg",
        "truncated" : false,
        "in_reply_to_status_id" : "",
        "annotations" : 
        [

        ],
        "in_reply_to_screen_name" : "",
        "geo" : null,
        "user" : 
        {
            "name" : "赵海俊的微薄",
            "domain" : "",
            "geo_enabled" : true,
            "followers_count" : 315,
            "statuses_count" : 2984,
            "favourites_count" : 53,
            "city" : "5",
            "description" : "运动健将",
            "verified" : false,
            "id" : 1668562204,
            "gender" : "m",
            "friends_count" : 611,
            "screen_name" : "赵海俊的微薄",
            "allow_all_act_msg" : false,
            "following" : false,
            "url" : "http://blog.sina.com.cn/eshesoulheart",
            "profile_image_url" : "http://tp1.sinaimg.cn/1668562204/50/1279885528/1",
            "created_at" : "Thu Dec 10 00:00:00 +0800 2009",
            "province" : "11",
            "location" : "北京 朝阳区"
        },
        "favorited" : false,
        "thumbnail_pic" : "http://ww3.sinaimg.cn/thumbnail/63743d1cjw6dbz63h1rfrj.jpg",
        "in_reply_to_user_id" : "",
        "id" : 4046214423,
        "source" : "<a href=\"http://tech.sina.com.cn/\" rel=\"nofollow\">新浪科技</a>"
    }
}

其他

Java示例

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

package weibo4j.examples;

import weibo4j.Status;
import weibo4j.Weibo;

public class UpdateComment {

	/**
	 * 对一条微博信息进行评论
	 * @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);
       	Status status = weibo.updateStatus("测试12345");//发表新微博信息
       	Thread.sleep(1000);
       	String sid = status.getId()+"";//微博id
       	System.out.println(sid + " : "+ status.getText()+"  "+status.getCreatedAt());
       	weibo.updateComment("测试评论", sid, null);//对刚发表的微博进行评论
       	Comment comment = weibo.updateComment("测试评论", sid, null);
       	System.out.println(comment.getId() + " : " + comment.getText() + "  " + comment.getCreatedAt());
		} 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示例

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

//Statuses/comment
// 对一条微博信息进行评论
$c = new WeiboClient( WB_AKEY , 
                      WB_SKEY , 
                      $_SESSION['last_key']['oauth_token'] , 
                      $_SESSION['last_key']['oauth_token_secret']  );
//发表新微博信息
$msg = $c->update("测试发表微博");
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;
}
//微博id
$sid = $msg['id'];
echo($sid." : ".$msg['text']." ".$msg["created_at"]);
sleep(5);
//对刚发表的微博进行评论
$msg = $c->send_comment($sid,"测试评论",null);
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;
}
echo($msg['id'].' : '.$msg['text'].'  '.$msg['created_at']);
文档更新时间: 2012-09-24