I'm building an app in Rails that needs to convert a Twitter ID into the Twitter username. This is the code that pulls the ID.
url = 'http://twitter.com/' + params[:username]
buffer = open(url, 'UserAgent' => 'irb').read
@vouched_user_twitter_id = buffer[/\d+(?=\.rss)/]
How do I use that number to pull the username once I no longer have params.
You can do this with the users/lookup method. This corresponds to the users method of this gem.
You can get the Twitter username from Twitter ID without using the Twitter API. Calling Twitter API has two issues:
It needs an access token after the release of Twitter API version 1.1.
The number of requests is limited to 150 requests per hour.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With