Created
June 8, 2012 17:18
-
-
Save ddd1600/2896960 to your computer and use it in GitHub Desktop.
Twitter API program ---tweet or get tweets using Grackle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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