Statuses/comments by me

跳转到: 导航, 搜索

目录

statuses/comments_by_me

获取当前用户发出的评论

URL

http://api.t.sina.com.cn/statuses/comments_by_me.(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。 返回结果的页码。

注意事项

返回结果

{{{result}}}

其他

Java示例

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

 package weibo4j.examples;
 
 import java.util.List;
 import weibo4j.Status;
 import weibo4j.Weibo;
 
 public class GetMentions {
 
 	/**
 	 * 获取@当前用户的微博列表 
 	 * @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);
         	List<Comment> comments = weibo.getCommentsTimeline();
		for (Comment comment: comments){
		    System.out.println(comment.getId()+":"+comment.getText()+" by "+comment.getUser().getScreenName());
		}
 	    } 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/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.";";
}