Statuses/unread

跳转到: 导航, 搜索
(请求参数)
 
(未显示3个用户的9个中间版本)
第1行: 第1行:
== statuses/unread ==
+
{{api_desc2|
获取当前用户Web未读消息数,包括@我的, 新评论,新私信,新粉丝数。
+
uri=statuses/unread |
 
+
desc=获取当前用户[http://t.sina.com.cn Web主站]未读消息数,包括:
此接口对应的清0接口目前正在开发中。
+
* 是否有新微博消息
 
+
* 最新提到“我”的微博消息数
{{Api_url|statuses/unread}}
+
* 新评论数
 
+
* 新私信数
{{Api_format|xml, json}}
+
* 新粉丝数。<br/>
+
此接口对应的清零接口为[[statuses/reset_count]]。|
{{Api_req|GET|true|true}}
+
format=XML/JSON|
 
+
httpMethod=GET|
===请求参数===
+
needAuth=true|
with_new_status:可选参数,默认为0。1表示结果包含是否有新微博,0表示结果不包含是否有新微博。
+
rateLimit=true|
*示例: http://api.t.sina.com.cn/statuses/unread.json?with_new_status=1
+
params={{api_args|with_new_status|false|int,默认为0。|1表示结果中包含new_status字段,0表示结果不包含new_status字段。new_status字段表示是否有新微博消息,1表示有,0表示没有}}
 
+
{{api_args|since_id|false|int64|参数值为微博id。该参数需配合with_new_status参数使用,返回since_id之后,是否有新微博消息产生}}|
===返回结果===
+
getParam=&with_new_status=1&since_id=300000000|
XML示例:
+
postParam=|
<?xml version="1.0" encoding="UTF-8"?>
+
result=
  <count>
+
===XML示例===
  <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 | 微博SDK开发包下载]] 处下载PHP SDK(支持OAuth验证之版本)<br>
+
代码示例如下:
+
 
<pre>
 
<pre>
//Statuses/unread
+
<?xml version="1.0" encoding="UTF-8"?>
$c = new WeiboClient( WB_AKEY ,
+
<count>
                      WB_SKEY ,
+
  <new_status>1</new_status>
                      $_SESSION['last_key']['oauth_token'] ,
+
  <followers>0</followers>
                      $_SESSION['last_key']['oauth_token_secret']  );
+
  <dm>1</dm>
 
+
  <mentions>1</mentions>
$msg = $c->oauth->get('http://api.t.sina.com.cn/statuses/unread.json');
+
  <comments>3</comments>
if ($msg === false || $msg === null){
+
</count>
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;
+
 
</pre>
 
</pre>
 +
===JSON示例===
 +
<pre>
 +
{
 +
    "comments" : 3,
 +
    "followers" : 0,
 +
    "new_status" : 1,
 +
    "dm" : 1,
 +
    "mentions" : 1
 +
}
 +
</pre>|
 +
useAge=
 +
* 如果只传入since_id,而没有传入with_new_status参数,则返回结果与未传入任何参数时相同。|
 +
otherInfo=无
 +
}}

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

目录

statuses/unread

获取当前用户Web主站未读消息数,包括:

  • 是否有新微博消息
  • 最新提到“我”的微博消息数
  • 新评论数
  • 新私信数
  • 新粉丝数。

此接口对应的清零接口为statuses/reset_count

URL

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

支持格式

XML/JSON

HTTP请求方式

GET

是否需要登录

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

请求数限制

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

请求参数

  必选 类型及范围 说明
source true string 申请应用时分配的AppKey,调用接口时候代表应用的唯一身份。(采用OAuth授权方式不需要此参数)
with_new_status false int,默认为0。 1表示结果中包含new_status字段,0表示结果不包含new_status字段。new_status字段表示是否有新微博消息,1表示有,0表示没有
since_id false int64 参数值为微博id。该参数需配合with_new_status参数使用,返回since_id之后,是否有新微博消息产生

注意事项

  • 如果只传入since_id,而没有传入with_new_status参数,则返回结果与未传入任何参数时相同。

返回结果

XML示例

<?xml version="1.0" encoding="UTF-8"?>
<count>
  <new_status>1</new_status>
  <followers>0</followers>
  <dm>1</dm>
  <mentions>1</mentions>
  <comments>3</comments>
</count>

JSON示例

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

其他

文档更新时间: 2012-09-24