简体   繁体   中英

How to use omniauth gem to get twitter user id?

I have a web application using omniauth-twitter gem for authentication purpose. I have to fetch the followers and following of the authenticated user into database But I am not able to figure out how would I use twitter gem to get the list of followers/following

I figured if you add the following lines of code to your omniauth.rb file which you must have created in / config / initializers / omniauth.rb, you have a twitter client and you are all set to use twitter gem. :-) It's fun to play around with Twitter gem. For more code, check out my project on github.. https://github.com/suhasdeshpande/DigFollowers

Rails.application.config.middleware.use OmniAuth::Builder do
   provider :twitter, 'Your Consumer key','Consumer Secret key'

   **Twitter.configure do |config|
    config.consumer_key = 'same goes here.. CK'
    config.consumer_secret = 'Consumer secret key'
   end**
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM