Statuses/comments by me
(→statuses/comments_by_me) |
|||
第1行: | 第1行: | ||
− | + | {{api_desc2| | |
− | + | uri=statuses/comments_by_me| | |
− | + | desc=获取当前用户发出的评论| | |
− | {{ | + | format=XML/JSON| |
− | + | httpMethod=GET| | |
− | {{ | + | needAuth=true| |
− | + | rateLimit=true| | |
− | {{ | + | params={{api_args|since_id|false|int64|若指定此参数,则只返回ID比since_id大的评论(比since_id发表时间晚)。}} |
− | + | {{api_args|max_id|false|int64|若指定此参数,则返回ID小于或等于max_id的评论}} | |
− | = | + | {{api_args|count|false|int,默认值20,最大值200。|单页返回的记录条数。}} |
− | + | {{api_args|page|false|int,默认值1。|返回结果的页码。}}| | |
− | + | getParam=&count=5&page=2| | |
− | + | postParam=| | |
− | + | ===XML示例=== | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | = | + | |
− | === | + | |
<pre> | <pre> | ||
− | + | <comment> | |
− | + | <created_at>Thu Nov 11 23:11:28 +0800 2010</created_at> | |
− | + | <id>4439022969</id> | |
− | <created_at> | + | <text>世界上最快的人~~~ They are just Genies~~</text> |
− | <id> | + | |
− | <text> | + | |
<user> | <user> | ||
− | <id> | + | <id>1658122963</id> |
− | <screen_name> | + | <screen_name>zhangwei217245</screen_name> |
− | <name> | + | <name>zhangwei217245</name> |
<province>11</province> | <province>11</province> | ||
− | <city> | + | <city>5</city> |
− | <location>北京 | + | <location>北京 朝阳区</location> |
− | <description> | + | <description>ABCDE</description> |
− | <url | + | <url/> |
− | <profile_image_url>http:// | + | <profile_image_url>http://tp4.sinaimg.cn/1658122963/50/1282754213</profile_image_url> |
− | <domain> | + | <domain>zhangwei217245</domain> |
<gender>m</gender> | <gender>m</gender> | ||
− | <followers_count> | + | <followers_count>22</followers_count> |
− | <friends_count> | + | <friends_count>43</friends_count> |
− | <statuses_count> | + | <statuses_count>0</statuses_count> |
− | <favourites_count> | + | <favourites_count>0</favourites_count> |
− | <created_at> | + | <created_at>Tue Nov 03 00:00:00 +0800 2009</created_at> |
<following>false</following> | <following>false</following> | ||
<verified>false</verified> | <verified>false</verified> | ||
<allow_all_act_msg>false</allow_all_act_msg> | <allow_all_act_msg>false</allow_all_act_msg> | ||
− | <geo_enabled> | + | <geo_enabled>true</geo_enabled> |
<status> | <status> | ||
− | <created_at> | + | <created_at>Wed Dec 01 12:46:20 +0800 2010</created_at> |
− | <id> | + | <id>3995822273</id> |
− | <text> | + | <text>Twitter的API文档页面竟然有BUG。。。那个可以收缩的API列表。。。无语。</text> |
<source> | <source> | ||
− | <a href=" | + | <a href="">微博开放平台接口</a> |
</source> | </source> | ||
<favorited>false</favorited> | <favorited>false</favorited> | ||
第64行: | 第55行: | ||
</user> | </user> | ||
<status> | <status> | ||
− | <created_at> | + | <created_at>Thu Nov 11 23:10:49 +0800 2010</created_at> |
− | <id> | + | <id>3583883787</id> |
− | <text> | + | <text>http://sinaurl.cn/7yJgU</text> |
<source> | <source> | ||
<a href="http://t.sina.com.cn">新浪微博</a> | <a href="http://t.sina.com.cn">新浪微博</a> | ||
第77行: | 第68行: | ||
<in_reply_to_screen_name/> | <in_reply_to_screen_name/> | ||
<user> | <user> | ||
− | <id> | + | <id>1658122963</id> |
− | <screen_name> | + | <screen_name>zhangwei217245</screen_name> |
− | <name> | + | <name>zhangwei217245</name> |
<province>11</province> | <province>11</province> | ||
− | <city> | + | <city>5</city> |
− | <location>北京 | + | <location>北京 朝阳区</location> |
− | <description> | + | <description>ABCDE</description> |
− | <url | + | <url/> |
− | <profile_image_url>http:// | + | <profile_image_url>http://tp4.sinaimg.cn/1658122963/50/1282754213</profile_image_url> |
− | <domain> | + | <domain>zhangwei217245</domain> |
<gender>m</gender> | <gender>m</gender> | ||
− | <followers_count> | + | <followers_count>22</followers_count> |
− | <friends_count> | + | <friends_count>43</friends_count> |
− | <statuses_count> | + | <statuses_count>0</statuses_count> |
− | <favourites_count> | + | <favourites_count>0</favourites_count> |
− | <created_at> | + | <created_at>Tue Nov 03 00:00:00 +0800 2009</created_at> |
<following>false</following> | <following>false</following> | ||
<verified>false</verified> | <verified>false</verified> | ||
<allow_all_act_msg>false</allow_all_act_msg> | <allow_all_act_msg>false</allow_all_act_msg> | ||
− | <geo_enabled> | + | <geo_enabled>true</geo_enabled> |
</user> | </user> | ||
</status> | </status> | ||
</comment> | </comment> | ||
+ | ... | ||
</comments> | </comments> | ||
</pre> | </pre> | ||
− | === | + | ===JSON示例=== |
<pre> | <pre> | ||
[ | [ | ||
− | + | { | |
− | + | "id" : 4439022969, | |
− | + | "text" : "世界上最快的人~~~ They are just Genies~~", | |
− | + | "created_at" : "Thu Nov 11 23:11:28 +0800 2010", | |
− | + | "user" : | |
− | + | { | |
− | + | "name" : "zhangwei217245", | |
− | + | "domain" : "zhangwei217245", | |
− | + | "geo_enabled" : true, | |
− | + | "followers_count" : 22, | |
− | + | "statuses_count" : 0, | |
− | + | "favourites_count" : 0, | |
− | + | "city" : "5", | |
− | + | "description" : "ABCDE", | |
− | + | "verified" : false, | |
− | + | "status" : | |
− | + | { | |
− | + | "created_at" : "Wed Dec 01 12:46:20 +0800 2010", | |
− | + | "text" : "Twitter的API文档页面竟然有BUG。。。那个可以收缩的API列表。。。无语。", | |
− | + | "truncated" : false, | |
− | + | "in_reply_to_status_id" : "", | |
− | + | "in_reply_to_screen_name" : "", | |
− | + | "geo" : null, | |
− | + | "favorited" : false, | |
− | + | "in_reply_to_user_id" : "", | |
− | + | "id" : 3995822273, | |
− | + | "source" : "<a href=\"\" 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" : "Thu Nov 11 23:10:49 +0800 2010", | |
− | + | "text" : "http://sinaurl.cn/7yJgU", | |
− | + | "truncated" : false, | |
− | + | "in_reply_to_status_id" : "", | |
− | + | "in_reply_to_screen_name" : "", | |
− | + | "geo" : null, | |
− | + | "user" : | |
− | + | { | |
− | + | "name" : "zhangwei217245", | |
− | + | "domain" : "zhangwei217245", | |
− | + | "geo_enabled" : true, | |
− | + | "followers_count" : 22, | |
− | + | "statuses_count" : 0, | |
− | + | "favourites_count" : 0, | |
− | + | "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" : 3583883787, | ||
+ | "source" : "<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>" | ||
+ | } | ||
+ | }, | ||
+ | ... | ||
] | ] | ||
</pre> | </pre> | ||
− | |||
− | |||
{{Param_comment}} | {{Param_comment}} | ||
− | + | {{Param_user}} | |
− | === | + | {{Param_status}}| |
− | + | useAge=无| | |
− | + | otherInfo= | |
− | + | ===Java示例=== | |
− | + | 请从 [[SDK | 微博SDK开发包下载]] 下载Java SDK<br> | |
− | + | 代码示意如下: | |
− | + | <pre> | |
− | + | 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; | ||
+ | } | ||
+ | } | ||
+ | </pre> | ||
+ | ===PHP示例=== | ||
请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br> | 请从 [[SDK | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br> | ||
代码示例如下: | 代码示例如下: | ||
第215行: | 第248行: | ||
} | } | ||
</pre> | </pre> | ||
+ | }} |
2010年12月1日 (三) 13:15的版本
目录 |
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.";"; }