Skip to content

Instantly share code, notes, and snippets.

@gom
Created February 10, 2009 05:06
Show Gist options
  • Save gom/61246 to your computer and use it in GitHub Desktop.
Save gom/61246 to your computer and use it in GitHub Desktop.
Post my status to twitter
#!/usr/bin/env ruby
require 'rubygems'
require 'twitter'
# config_file format from:
# http://twitter4r.rubyforge.org/rdoc/classes/Twitter/Client.html#M000050
#
# envname:
# login: mytwitterlogin
# password: mytwitterpassword
#
config_file = File.join(File.dirname(__FILE__), 'tw.yml')
twitter = Twitter::Client.from_config(config_file)
# Get Friends Timeline
puts "***** ***** *****"
timeline = twitter.timeline_for(:friends, :count => 10) do |status|
puts "#{status.user.screen_name}: #{status.text}"
end
puts
# Post Message
msg = $*.join(" ")
exit if msg.empty?
begin
status = twitter.status :post, msg
rescue => e
puts e
end
puts "posted => " + msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment