Statuses/unread

跳转到: 导航, 搜索
(请求参数)
(请求参数)
第11行: 第11行:
  
 
===请求参数===
 
===请求参数===
with_new_status:可选参数,默认为0。1表示结果包含是否有新微博,0表示结果不包含是否有新微博。
+
*示例: http://api.t.sina.com.cn/statuses/unread.json?with_new_status=1
+
  
 
===返回结果===
 
===返回结果===

2010年10月19日 (二) 10:51的版本

目录

statuses/unread

获取当前用户Web未读消息数,包括@我的, 新评论,新私信,新粉丝数。

此接口对应的清0接口目前正在开发中。

URL

http://api.t.sina.com.cn/statuses/unread.format

格式

xml, json

HTTP请求方式

GET

是否需要登录

true

请求数限制

true

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

请求参数

返回结果

XML示例:

<?xml version="1.0" encoding="UTF-8"?>
 <count>
  <comments>10</comments>
  <mentions>0</mentions>
  <dm>0</dm>
  <followers>2</followers>
 <count>

JSON示例:

  {"comments":0,
  "dm":1,
   "mentions":2,
  "followers":3}

使用示例:

需修改appkey

  • xml:

curl -u uid:password http://api.t.sina.com.cn/statuses/unread.xml?source=appkey

  • json:

curl -u uid:password http://api.t.sina.com.cn/statuses/unread.json?source=appkey

PHP示例

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

//Statuses/unread
$c = new WeiboClient( WB_AKEY , 
                      WB_SKEY , 
                      $_SESSION['last_key']['oauth_token'] , 
                      $_SESSION['last_key']['oauth_token_secret']  );

$msg = $c->oauth->get('http://api.t.sina.com.cn/statuses/unread.json');
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;
}
$followers = $msg['followers'];
$dm = $msg['dm'];
$mentions = $msg['mentions'];
$comments = $msg['comments'];
echo $followers.','.$dm.','.$mentions.','.$comments;