Account/rate limit status/en

跳转到: 导航, 搜索

目录

account/rate_limit_status

Retrieve the rate limitation of API calls. Return how many times API can be called in this hour. This limitation is based on the user type. Details can be found at Interface Access Rating Limitation Statement

URL

http://api.t.sina.com.cn/account/rate_limit_status.(json%7Cxml)

Supported Formats

XML/JSON

HTTP Request Method

GET

Requires Authentication

true
See the Authorization Mechanism Statement for authorization details

Requests Count Limitation

true
See the Interface Access Rights Statement for the Request Count Limitaiton details.

Request Parameters

  Requires Type and Range Description
source true string AppKey for the application to identify it. ( This parameter is not needed when using OAuth)

Notes

None

Example Request

XML
curl -u "username:password" "http://api.t.sina.com.cn/account/rate_limit_status.xml?source=appkey"
JSON
curl -u "username:password" "http://api.t.sina.com.cn/account/rate_limit_status.json?source=appkey"

Response

XML Example

<?xml version="1.0" encoding="UTF-8"?>
 <hash>
  <remaining-hits type="integer">150</remaining-hits>
  <hourly-limit type="integer">150</hourly-limit>
  <reset-time-in-seconds type="integer">1264994233</reset-time-in-seconds>
  <reset-time type="datetime">Mon Feb 01 03:15:22 +0800 2010</reset-time>
 </hash>

JSON Example

{
   "hourly_limit":150,
   "reset_time_in_seconds":1264994122,
   "reset_time":"Mon Feb 01 03:15:22 +0800 2010",
   "remaining_hits":150
}

Others

Java Example

Please download Java SDK from . Weibo SDK Development Kit Dowload Site
Sample Code:

package weibo4j.examples.account;

import weibo4j.RateLimitStatus;
import weibo4j.Weibo;
import weibo4j.WeiboException;

public class GetRateLimitStatus {
	/**
	 * 获取当前用户API访问频率限制
	 * @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 = new Weibo();
			weibo.setToken(args[0], args[1]);
			RateLimitStatus limitStatus = weibo.rateLimitStatus();
			System.out.println(limitStatus.toString());
		} catch (WeiboException e) {
			e.printStackTrace();
		}
	}
}

PHP Example

Please download PHP SDK with OAUTH supported from Weibo SDK Development Kit Dowload Site
. Sample Code:

//account/rate_limit_status
//获取当前用户API访问频率限制
$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/account/rate_limit_status.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;
}
if (isset($msg['hourly_limit'])){
	echo($msg['hourly_limit']);
}