Ruby on rails 适用于多用户的rails-twitter-gem

Ruby on rails 适用于多用户的rails-twitter-gem,ruby-on-rails,twitter-gem,Ruby On Rails,Twitter Gem,使用twitter gem,我想获得经过身份验证的用户的所有追随者。不过,我只获得该应用程序的注册twitter id的追随者 我在初始化器中有一个twitter.rb,它使用twitter上注册应用程序的消费者密钥/密码 Twitter.configure do |config| config.consumer_key = '****' config.consumer_secret = '****' end 当您登录时,您可以通过Desive进行登录。然后,在用户配置文件中,

使用twitter gem,我想获得经过身份验证的用户的所有追随者。不过,我只获得该应用程序的注册twitter id的追随者

我在初始化器中有一个twitter.rb,它使用twitter上注册应用程序的消费者密钥/密码

Twitter.configure do |config|
    config.consumer_key = '****'
    config.consumer_secret = '****'
end
当您登录时,您可以通过Desive进行登录。然后,在用户配置文件中,用户可以通过Twitter进行身份验证,此时我存储令牌和密码

def create
    auth = request.env["omniauth.auth"]
    currentAuthentication = Authentication.find_by_provider_and_uid(auth['provider'], auth['uid'])
    if currentAuthentication
        flash[:notice] = "Logged in successfully."
    else
        current_user.authentications.create(:provider => auth['provider'], :uid => auth['uid'], :token => auth['credentials']['token'], :secret => auth['credentials']['secret'])
        flash[:notice] = "Authentication successful."
    end

    redirect_to authentications_url
end
然后在稍后的阶段,我用我存储的信息验证该用户,并希望获得他的追随者

  def getwords
    # authenticate at twitter
    authenticationDetails = current_user.authentications.first()
    wordClient = Twitter::Client.new(
        :oauth_token => authenticationDetails.token,
        :oauth_token_secret => authenticationDetails.secret
        )

    # get the users followers
    #wordClient.update("I'm tweeting using the Twitter Gem.")
    cursor = "-1"
    followerIds = []
    while cursor != 0 do
      followers = wordClient.follower_ids

      cursor = followers.next_cursor
      followerIds+= followers.ids
      sleep(2)
    end

    return followerIds
  end
当我执行wordClient.update时,我从注册的应用程序发送了一条tweet,并且我还获得了注册应用程序的追随者


我本想发一条推特,得到认证用户的追随者?我哪里做错了?我能找到的所有例子都是基于一个用户的twitter

上面的代码实际上运行良好。我遇到的问题是,我错过了身份验证表中uid的唯一约束,这导致同一个人有两个条目。