Skip to content

Instantly share code, notes, and snippets.

@lgs
Created September 14, 2008 12:54
Show Gist options
  • Save lgs/10727 to your computer and use it in GitHub Desktop.
Save lgs/10727 to your computer and use it in GitHub Desktop.
useraxis@useraxis.org [~/rails/masquerade]# ruby script/console
Loading development environment (Rails 2.1.0)
>> class Twitter
>> include HTTParty
>> base_uri 'twitter.com'
>>
?>
?> def initialize(u, p)
>> @auth = {:username => u, :password => p}
>> end
>>
?> def post(text)
>> options = { :query => {:status => text}, :basic_auth => @auth }
>>
?> self.class.post('/statuses/update.json', options)
>> end
>> end
=> nil
>>
?> Twitter.new('lgswitter', 'xxxxx').post("Here another HTTParty test: I'm posting via Rails script/console ")
=> {"user"=>{"name"=>"Luca G.Soave", "url"=>nil, "id"=>14926752, "description"=>"", "protected"=>false, "screen_name"=>"lgswitter", "followers_count"=>2, "profile_image_url"=>"http://s3.amazonaws.com/twitter_production/profile_images/54745327/luca_normal.jpg", "location"=>"Italy "}, "favorited"=>false, "truncated"=>false, "text"=>"Here another HTTParty test: I'm posting via Rails script/console", "id"=>920995162, "in_reply_to_user_id"=>nil, "in_reply_to_status_id"=>nil, "source"=>"web", "created_at"=>"Sun Sep 14 12:43:25 +0000 2008"}
>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment