Difference between revisions of "Twitter Rate Limiting - How To Handle"

From Hostek.com Wiki
Jump to: navigation, search
m (Caching)
m (Use the Twitter REST API)
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
==How to Avoid Twitter's Rate Limits==
 
==How to Avoid Twitter's Rate Limits==
 
===Caching===
 
===Caching===
The best way to prevent your site from reaching this limit is to cache your calls to Twitter for at least 1-5 minutes. This can be done easily using the ColdFusion (9+) caching functions described in [http://www.aaronwest.net/blog/index.cfm/2009/11/22/14-Days-of-ColdFusion-9-Caching-Day-6--Using-cachePut-cacheGet-and-cacheGetMetadata this blog post].
+
The best way to prevent your site from reaching this limit is to cache your calls to Twitter for at least 1-5 minutes. This can be done easily using the ColdFusion (9+) caching functions described in [http://www.aaronwest.net/blog/index.cfm/2009/11/22/14-Days-of-ColdFusion-9-Caching-Day-6--Using-cachePut-cacheGet-and-cacheGetMetadata this blog post]. If your application is written in PHP, ASP, or .NET a similar approach can be used -- you could simply store the results of the http call in a variable then set a counter for when the variable needs to be updated.
  
 
===Use the Twitter REST API===
 
===Use the Twitter REST API===
Additionally, you may wish to consider using Twitter's REST-base API as it will give you a higher limit for searches. More details on getting started with the Twitter API can be found at [https://dev.twitter.com/docs/api Twitter's API Documentation page]. More info on getting started integrating your application with Twitter can be found at the [https://dev.twitter.com/ Twitter Developers Portal].
+
Additionally, you may wish to consider using Twitter's REST-based API as it will give you a higher limit for searches. More details on getting started with the Twitter API can be found at [https://dev.twitter.com/docs/api Twitter's API Documentation page]. More info on getting started integrating your application with Twitter can be found at the [https://dev.twitter.com/ Twitter Developers Portal].
 +
 
 +
[[Category:ColdFusion]]
 +
[[Category:VPS]]
 +
[[Category:ColdFusion-VPS]]
 +
[[Category:Railo-VPS]]
 +
[[Category:Linux-VPS]]
 +
[[Category:Windows-VPS]]

Latest revision as of 21:47, 5 May 2013

Background

It is common to want to include a user's Twitter feed on your Web site, and this can easily be done by calling Twitter's anonymous ATOM search URL (eg. http://search.twitter.com/search.atom?q=Hostek). The downside to using this approach is that the anonymous search utility is rate limited to 150 searches per hour per IP. As such, if other sites on your server also call Twitter's anonymous search URL, you may eventually receive an error stating "Clients may not make more than 150 requests per hour."

How to Avoid Twitter's Rate Limits

Caching

The best way to prevent your site from reaching this limit is to cache your calls to Twitter for at least 1-5 minutes. This can be done easily using the ColdFusion (9+) caching functions described in this blog post. If your application is written in PHP, ASP, or .NET a similar approach can be used -- you could simply store the results of the http call in a variable then set a counter for when the variable needs to be updated.

Use the Twitter REST API

Additionally, you may wish to consider using Twitter's REST-based API as it will give you a higher limit for searches. More details on getting started with the Twitter API can be found at Twitter's API Documentation page. More info on getting started integrating your application with Twitter can be found at the Twitter Developers Portal.