Search code examples
rubytwittertwitter-gem

How can I retrieve my profile with the twitter gem


client = Twitter::REST::Client.new do |config|
  config.consumer_key        = "XX"
  config.consumer_secret     = "XY"
  config.access_token        = "ZZ"
  config.access_token_secret = "ZZZ"
end

How can I retrieve my profile information?


Solution

  • You can do the following simple steps to use the Twitter client gem:

    # get user id from user name 
    id = client.user( 'user_name' ).id
    
    # read user's timeline by id
    timeline = client.user_timeline id
    
    # read user's timeline of yours
    your_timeline = client.user_timeline
    

    you can omit the username, and you get the timeline of current user, so try also to issue:

    user_info = client.user