简体   繁体   English

如何使用omniauth gem获取Twitter用户ID?

[英]How to use omniauth gem to get twitter user id?

I have a web application using omniauth-twitter gem for authentication purpose. 我有一个使用omniauth-twitter gem进行身份验证的Web应用程序。 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 我必须将已验证用户的关注者和关注者获取到数据库中,但是我无法弄清楚如何使用twitter gem获取关注者/关注者的列表

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. 我想过,如果将以下代码行添加到必须在/config/initializers/omniauth.rb中创建的omniauth.rb文件中,则有一个twitter客户端,并且都已设置为使用twitter gem。 :-) It's fun to play around with Twitter gem. :-)玩Twitter宝石很有趣。 For more code, check out my project on github.. https://github.com/suhasdeshpande/DigFollowers 有关更多代码,请在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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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