Skip to content

Instantly share code, notes, and snippets.

@ddd1600
Created June 8, 2012 17:18
Show Gist options
  • Save ddd1600/2896960 to your computer and use it in GitHub Desktop.
Save ddd1600/2896960 to your computer and use it in GitHub Desktop.
Twitter API program ---tweet or get tweets using Grackle
require 'grackle'
require 'json'
require 'highline/import'
$client = Grackle::Client.new(:auth=>{
:type => :oauth,
:consumer_key => 'YOUR_CONSUMER_KEY', :consumer_secret => 'YOUR_CONSUMER_SECRET',
:token => 'YOUR_ACCCESS_TOKEN', :token_secret => 'YOUR_ACCESS_TOKEN_SECRET'
})
class Twitter
def getJsonData
@json = $client.users.show? :screen_name=>'ddd1600' #http://twitter.com/users/show.json?screen_name=ddd1600
end
def parseData
parsed_json = ActiveSupport::JSON.decode(your_json_string)
end
def getTweet
@input = ask("What do you want your tweet to say?")
end
def tweet
$client.statuses.update! :status=> @input #POST to http://twitter.com/statuses/update.jso
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment