Error with Ruby Twitter API

后端 未结 1 1132
难免孤独
难免孤独 2021-01-02 05:06

I am getting an error with a Ruby script using the \'twitter\' gem. The part of my script that is producing the error is

require \'twitter\'
require \'net/         


        
相关标签:
1条回答
  • 2021-01-02 05:28

    You are doing it the "old" way. Starting in Version 5, global configuration is not longer available. So, basically you need to pass the config parameters when you initialize a client.

    For example:

    client = Twitter::REST::Client.new do |config|
      config.consumer_key        = "YOUR_CONSUMER_KEY"
      config.consumer_secret     = "YOUR_CONSUMER_SECRET"
      config.access_token        = "YOUR_ACCESS_TOKEN"
      config.access_token_secret = "YOUR_ACCESS_SECRET"
    end
    

    And then just use that client to do queries, such as:

    client.sample do |tweet|
      puts tweet.text
    end
    

    For more information just refer to Sferik's Twitter Gem

    0 讨论(0)
提交回复
热议问题