Permalink
Browse files

attempt to use twitter oauth to post updates

  • Loading branch information...
qrush committed Sep 1, 2010
1 parent a8e9ae5 commit 6a05097774deaf66d4e6a5209d0b822a1562393a
Showing with 13 additions and 5 deletions.
  1. +1 −0 .gems
  2. +12 −5 gemwhisperer.rb
View
1 .gems
@@ -1 +1,2 @@
sinatra-activerecord
+twitter
View
@@ -2,6 +2,11 @@
require 'sinatra/activerecord'
require 'haml'
require 'json'
+require 'twitter'
+
+oauth = Twitter::OAuth.new(ENV['CONSUMER_KEY'], ENV['CONSUMER_SECRET'])
+oauth.authorize_from_access(ENV['REQUEST_TOKEN'], ENV['REQUEST_SECRET'])
+client = Twitter::Base.new(oauth)
configure :development do
ActiveRecord::Base.establish_connection(:adapter => "sqlite3",
@@ -23,11 +28,13 @@ class Whisper < ActiveRecord::Base
post '/' do
begin
- hash = JSON.parse(request.body.read)
- Whisper.create(:name => hash["name"],
- :version => hash["version"],
- :url => hash["project_uri"],
- :info => hash["info"])
+ hash = JSON.parse(request.body.read)
+ whisper = Whisper.create(:name => hash["name"],
+ :version => hash["version"],
+ :url => hash["project_uri"],
+ :info => hash["info"])
+
+ client.update("#{whisper.name} (#{whisper.version}): #{whisper.url}")
rescue Exception => ex
# oops!
end

0 comments on commit 6a05097

Please sign in to comment.