Statuses/mentions

跳转到: 导航, 搜索

目录

statuses/mentions

返回最新n条提到登录用户的微博消息(即包含@username的微博消息)

URL

http://api.t.sina.com.cn/statuses/mentions.(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。 返回结果的页码。注意:有分页限制。

注意事项

返回结果

XML示例

 <?xml version="1.0" encoding="UTF-8"?>
<statuses>
  <status>
    <created_at>Tue Sep 07 12:50:46 +0800 2010</created_at>
    <id>2381621377</id>
    <text>实诚人。 //@loo00://@huchao:这个太亮了...</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/>
    <user>
      <id>1403132707</id>
      <screen_name>madmole</screen_name>
      <name>madmole</name>
      <province>11</province>
      <city>8</city>
      <location>北京 海淀区</location>
      <description/>
      <url>http://blog.sina.com.cn/madmole</url>
      <profile_image_url>http://tp4.sinaimg.cn/1403132707/50/1279878220</profile_image_url>
      <domain>madmole</domain>
      <gender>m</gender>
      <followers_count>74</followers_count>
      <friends_count>103</friends_count>
      <statuses_count>547</statuses_count>
      <favourites_count>4</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>Tue Sep 07 09:55:42 +0800 2010</created_at>
      <id>2377078389</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/>
      <thumbnail_pic>http://ss6.sinaimg.cn/thumbnail/61e8a1fdg8fa1b0a50c95&690</thumbnail_pic>
      <bmiddle_pic>http://ss6.sinaimg.cn/bmiddle/61e8a1fdg8fa1b0a50c95&690</bmiddle_pic>
      <original_pic>http://ss6.sinaimg.cn/orignal/61e8a1fdg8fa1b0a50c95&690</original_pic>
      <user>
        <id>1642635773</id>
        <screen_name>我们爱讲冷笑话</screen_name>
        <name>我们爱讲冷笑话</name>
        <province>11</province>
        <city>1</city>
        <location>北京 东城区</location>
        <description>我们爱讲冷笑话lengxiaohua.net官方微博</description>
        <url>http://lengxiaohua.net</url>
        <profile_image_url>http://tp2.sinaimg.cn/1642635773/50/1283204219</profile_image_url>
        <domain>lengxiaohua</domain>
        <gender>f</gender>
        <followers_count>250573</followers_count>
        <friends_count>6</friends_count>
        <statuses_count>3215</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>
  </status>
  <status>
    <created_at>Tue Sep 07 10:27:45 +0800 2010</created_at>
    <id>2377870842</id>
    <text>//@huchao:这个太亮了...</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/>
    <user>
      <id>1642473375</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/1642473375/50/1279882929</profile_image_url>
      <domain>adayaxx</domain>
      <gender>f</gender>
      <followers_count>86</followers_count>
      <friends_count>71</friends_count>
      <statuses_count>615</statuses_count>
      <favourites_count>1</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>Tue Sep 07 09:55:42 +0800 2010</created_at>
      <id>2377078389</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/>
      <thumbnail_pic>http://ss6.sinaimg.cn/thumbnail/61e8a1fdg8fa1b0a50c95&690</thumbnail_pic>
      <bmiddle_pic>http://ss6.sinaimg.cn/bmiddle/61e8a1fdg8fa1b0a50c95&690</bmiddle_pic>
      <original_pic>http://ss6.sinaimg.cn/orignal/61e8a1fdg8fa1b0a50c95&690</original_pic>
      <user>
        <id>1642635773</id>
        <screen_name>我们爱讲冷笑话</screen_name>
        <name>我们爱讲冷笑话</name>
        <province>11</province>
        <city>1</city>
        <location>北京 东城区</location>
        <description>我们爱讲冷笑话lengxiaohua.net官方微博</description>
        <url>http://lengxiaohua.net</url>
        <profile_image_url>http://tp2.sinaimg.cn/1642635773/50/1283204219</profile_image_url>
        <domain>lengxiaohua</domain>
        <gender>f</gender>
        <followers_count>250573</followers_count>
        <friends_count>6</friends_count>
        <statuses_count>3215</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>
  </status>
</statuses>

JSON示例

  [
   {
      "created_at":"Tue Sep 07 12:50:46 +0800 2010",
      "id":2381621377,
      "text":"实诚人。 //@loo00://@huchao:这个太亮了...",
      "source":"<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>",
      "favorited":false,
      "truncated":false,
      "in_reply_to_status_id":"",
      "in_reply_to_user_id":"",
      "in_reply_to_screen_name":"",
      "geo":null,
      "user":{
         "id":1403132707,
         "screen_name":"madmole",
         "name":"madmole",
         "province":"11",
         "city":"8",
         "location":"北京 海淀区",
         "description":"",
         "url":"http://blog.sina.com.cn/madmole",
         "profile_image_url":"http://tp4.sinaimg.cn/1403132707/50/1279878220",
         "domain":"madmole",
         "gender":"m",
         "followers_count":74,
         "friends_count":103,
         "statuses_count":547,
         "favourites_count":4,
         "created_at":"Fri Aug 28 00:00:00 +0800 2009",
         "following":false,
         "allow_all_act_msg":false,
         "geo_enabled":false,
         "verified":false
      },
      "retweeted_status":{
         "created_at":"Tue Sep 07 09:55:42 +0800 2010",
         "id":2377078389,
         "text":"发布招聘启事的家伙肯定收了经理啥好处了~~",
         "source":"<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>",
         "favorited":false,
         "truncated":false,
         "in_reply_to_status_id":"",
         "in_reply_to_user_id":"",
         "in_reply_to_screen_name":"",
         "thumbnail_pic":"http://ss6.sinaimg.cn/thumbnail/61e8a1fdg8fa1b0a50c95&690",
         "bmiddle_pic":"http://ss6.sinaimg.cn/bmiddle/61e8a1fdg8fa1b0a50c95&690",
         "original_pic":"http://ss6.sinaimg.cn/orignal/61e8a1fdg8fa1b0a50c95&690",
         "geo":null,
         "user":{
            "id":1642635773,
            "screen_name":"我们爱讲冷笑话",
            "name":"我们爱讲冷笑话",
            "province":"11",
            "city":"1",
            "location":"北京 东城区",
            "description":"我们爱讲冷笑话lengxiaohua.net官方微博",
            "url":"http://lengxiaohua.net",
            "profile_image_url":"http://tp2.sinaimg.cn/1642635773/50/1283204219",
            "domain":"lengxiaohua",
            "gender":"f",
            "followers_count":250573,
            "friends_count":6,
            "statuses_count":3215,
            "favourites_count":0,
            "created_at":"Fri Aug 28 00:00:00 +0800 2009",
            "following":false,
            "allow_all_act_msg":false,
            "geo_enabled":false,
            "verified":false
         }
      }
   },
   {
      "created_at":"Tue Sep 07 10:27:45 +0800 2010",
      "id":2377870842,
      "text":"//@huchao:这个太亮了...",
      "source":"<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>",
      "favorited":false,
      "truncated":false,
      "in_reply_to_status_id":"",
      "in_reply_to_user_id":"",
      "in_reply_to_screen_name":"",
      "geo":null,
      "user":{
         "id":1642473375,
         "screen_name":"娄阿姨叫小白兔",
         "name":"娄阿姨叫小白兔",
         "province":"11",
         "city":"8",
         "location":"北京 海淀区",
         "description":"老不正经",
         "url":"http://1",
         "profile_image_url":"http://tp4.sinaimg.cn/1642473375/50/1279882929",
         "domain":"adayaxx",
         "gender":"f",
         "followers_count":86,
         "friends_count":71,
         "statuses_count":615,
         "favourites_count":1,
         "created_at":"Fri Aug 28 00:00:00 +0800 2009",
         "following":false,
         "allow_all_act_msg":false,
         "geo_enabled":false,
         "verified":false
      },
      "retweeted_status":{
         "created_at":"Tue Sep 07 09:55:42 +0800 2010",
         "id":2377078389,
         "text":"发布招聘启事的家伙肯定收了经理啥好处了~~",
         "source":"<a href=\"http://t.sina.com.cn\" rel=\"nofollow\">新浪微博</a>",
         "favorited":false,
         "truncated":false,
         "in_reply_to_status_id":"",
         "in_reply_to_user_id":"",
         "in_reply_to_screen_name":"",
         "thumbnail_pic":"http://ss6.sinaimg.cn/thumbnail/61e8a1fdg8fa1b0a50c95&690",
         "bmiddle_pic":"http://ss6.sinaimg.cn/bmiddle/61e8a1fdg8fa1b0a50c95&690",
         "original_pic":"http://ss6.sinaimg.cn/orignal/61e8a1fdg8fa1b0a50c95&690",
         "geo":null,
         "user":{
            "id":1642635773,
            "screen_name":"我们爱讲冷笑话",
            "name":"我们爱讲冷笑话",
            "province":"11",
            "city":"1",
            "location":"北京 东城区",
            "description":"我们爱讲冷笑话lengxiaohua.net官方微博",
            "url":"http://lengxiaohua.net",
            "profile_image_url":"http://tp2.sinaimg.cn/1642635773/50/1283204219",
            "domain":"lengxiaohua",
            "gender":"f",
            "followers_count":250573,
            "friends_count":6,
            "statuses_count":3215,
            "favourites_count":0,
            "created_at":"Fri Aug 28 00:00:00 +0800 2009",
            "following":false,
            "allow_all_act_msg":false,
            "geo_enabled":false,
            "verified":false
         }
      }
   }
]

字段说明 - status

  • created_at: 创建时间
  • id: 微博ID
  • text: 微博信息内容
  • source: 微博来源
  • favorited: 是否已收藏
  • truncated: 是否被截断
  • in_reply_to_status_id: 回复ID
  • in_reply_to_user_id: 回复人UID
  • in_reply_to_screen_name: 回复人昵称
  • thumbnail_pic: 缩略图
  • bmiddle_pic: 中型图片
  • original_pic:原始图片
  • user: 作者信息
  • retweeted_status: 转发的博文,内容为status,如果不是转发,则没有此字段

字段说明 - user

  • id: 用户UID
  • screen_name: 微博昵称
  • name: 友好显示名称,同微博昵称
  • province: 省份编码(参考省份编码表)
  • city: 城市编码(参考城市编码表)
  • location:地址
  • description: 个人描述
  • url: 用户博客地址
  • profile_image_url: 自定义图像
  • domain: 用户个性化URL
  • gender: 性别,m--男,f--女,n--未知
  • followers_count: 粉丝数
  • friends_count: 关注数
  • statuses_count: 微博数
  • favourites_count: 收藏数
  • created_at: 创建时间
  • following: 是否已关注(此特性暂不支持)
  • verified: 加V标示,是否微博认证用户

其他

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<Status> list = weibo.getMentions();
        	for(Status status : list) {
        		System.out.println( status.getId() + "  : "+status.getText());
        	}
		} 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/mentions
//获取@当前用户的微博列表
$c = new WeiboClient( WB_AKEY , 
                      WB_SKEY , 
                      $_SESSION['last_key']['oauth_token'] , 
                      $_SESSION['last_key']['oauth_token_secret']  );
$msg  = $c->mentions();
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){
	$id = $data['id'];
	$text = $data['text'];
	echo $id."=".$text.";";
}
文档更新时间: 2012-09-24