Skip to content

Instantly share code, notes, and snippets.

@unnitallman
Created November 13, 2013 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unnitallman/7448221 to your computer and use it in GitHub Desktop.
Save unnitallman/7448221 to your computer and use it in GitHub Desktop.
Convert twitter username to user id
Add the gem "twitter" to Gemfile.
client = Twitter::Client.new(
:consumer_key => "key",
:consumer_secret => "secret",
)
[8] pry(main) client.users("unnitallman")[0].id
=> 11976602
[8] pry(main)> client.users("ershus")[0].id
=> 29364787
client.users(["ershus","unnitallman"])[0].id
=> 29364787
[3] pry(main)> client.users(["ershus","unnitallman"])[1].id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment