Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test the twitter API locally?

Tags:

oauth

twitter

I'm trying to write a web application that would use Twitter via OAuth.

  1. I run my local server as 'localhost', so I need the callback URL to be something like http://localhost/something/twitter.do but Twitter doesn't like that: Not a valid URL format

  2. I'm probably going to do a lot of tests, but once I've approved my app with my username, I can't test again can I? Am I supposed to create multiple twitter accounts? Or can you remove an app and do it again?

like image 723
Nathan H Avatar asked Nov 13 '09 02:11

Nathan H


People also ask

Is the Twitter API free?

Twitter API access levels and versions The Twitter API v2 includes a few access levels to help you scale your usage on the platform. In general, new accounts can quickly sign up for free, Essential access. Should you want additional access, you may choose to apply for free Elevated access and beyond.


2 Answers

  1. You can use 127.0.0.1 instead of localhost.

  2. You can authorize your app as many times as you like from the same twitter account without the necessity to revoke it. However, the authenticate action will only prompt for Allow/Deny once and all subsequent authenticate requests will just pass through until you revoke the privilege.

like image 186
anushr Avatar answered Nov 18 '22 14:11

anushr


Twitter's "rate limiting" for API GET calls is based on IP address of the caller. So, you can test your app from your server, using the same IP address, and get (once approved) 15,000 API calls per hour. That means you can pound on your app with many different usernames, as long as your approved IP address remains the same.

When you send the e-mail to Twitter to ask for an increase to your rate limit, you can also ask for the increase to apply to your Twitter username too.

I believe Twitter requires you - if you need to change your IP address, or change the username that is using the app - to send in another request asking for the rate limit increase for that new IP address or username. But, in my experience, Twitter has been pretty quick at turning around these requests (maybe less than 48 hours?).

like image 22
chipmunkgeek Avatar answered Nov 18 '22 14:11

chipmunkgeek