[英]How to check rate_limit_status in response header in C#
We see that our rate limit is being reached in our Twitter calls, I did some research: 我们看到我们的Twitter通话已达到速率限制,我做了一些研究:
https://dev.twitter.com/docs/rate-limiting/1.1 https://dev.twitter.com/docs/rate-limiting/1.1
They suggested checking this rate_limit_status once in a while explained here: 他们建议不时检查一下rate_limit_status,在此进行解释:
https://dev.twitter.com/docs/api/1.1/get/application/rate_limit_status https://dev.twitter.com/docs/api/1.1/get/application/rate_limit_status
So, I would like to know how to check that in the code. 因此,我想知道如何在代码中进行检查。 Can I do something like this? 我可以做这样的事情吗?
string rateLimit = twitterService.Response.Headers["application/rate_limit_status"];
My questions are: 我的问题是:
Do I then just parse the rateLimit? 然后我只解析rateLimit吗? Because it is a JSON/XML 因为它是JSON / XML
According to the API, it contains 根据API,它包含
"remaining": "reset": "limit":
So, let's say I want to reset the rate limit once it hits closer to the limit, what should I do? 因此,假设我想在速率限制接近极限时重设速率限制,该怎么办?
Any help is greatly appreciated. 任何帮助是极大的赞赏。
do i then just parse the rateLimit?because it is a JSON/XML 那我只是解析rateLimit吗?因为它是JSON / XML
Yes, for example using Json.NET . 是的,例如使用Json.NET 。
if I want to reset the rate limit once it hits closer to the limit, what should I do? 如果我想重新设置速率限制,使其接近限制,我该怎么办?
You can't do anything but wait until the reset
moment, it's a timestamp. 您别无选择,只能等到reset
时刻,这是一个时间戳记。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.