Created
February 10, 2009 05:06
-
-
Save gom/61246 to your computer and use it in GitHub Desktop.
Post my status to twitter
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
#!/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