mutewinter / Showbot

🤖 An IRC Bot and Website for 5by5.tv written with the Cinch and Sinatra frameworks
MIT License
90 stars 31 forks source link

Adds OAuth to the twitter broadcast plugin. #48

Closed rikai closed 11 years ago

rikai commented 11 years ago

This commit adds OAuth to the twitter broadcast plugin to work with the twitter API v1.1.

Explanation: I noticed i started getting errors related to twitter in the server log basically boiling down to:

~/.rvm/gems/ruby-1.9.2-p320/gems/twitter-4.5.0/lib/twitter/response/raise_error.rb:21:in `on_complete': Bad Authentication data (Twitter::Error::BadRequest)

After some poking around, i believe this may be due to twitter phasing out the 1.0 API very soon?

The simple and quick fix i found for this was to follow the instructions over on the twitter gem site and add to twitter_broadcast.rb

Twitter.configure do |config|
  config.consumer_key = YOUR_CONSUMER_KEY
  config.consumer_secret = YOUR_CONSUMER_SECRET
  config.oauth_token = YOUR_OAUTH_TOKEN
  config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
end

as shown in commit c97715f9c4307fe037771a8a13c86f45bb9fa9b4 and then registering the application with a twitter account and plugging things in the the proper locations.

This fix seems to work in my very limited testing.

There may be easier/cleaner ways to do this, but this seems to be the most straightforward way of doing it with the current code structure and with the 1.0 API cutoff looming, I figured i'd push the quick fix upstream. ;)

This config stuff is probably something that should be considered as part of issue #31 later on, so i'll reference it here so it's not forgotten. :)

mutewinter commented 11 years ago

merged :)