Skip to content

Instantly share code, notes, and snippets.

@ivey
Created October 30, 2009 21:00
Show Gist options
  • Save ivey/222729 to your computer and use it in GitHub Desktop.
Save ivey/222729 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
require 'twitter'
require 'sqlite3'
db = SQLite3::Database.new( "favorites.db" )
source = "http://twitter.com/favorites/USERID_TO_FETCH.rss"
content = ""
open(source) { |s| content = s.read }
rss = RSS::Parser.parse(content, false)
exit unless rss
twitter = Twitter::Base.new('USER_TO_POST_AS', 'PASSWORD')
count = 1
rss.items.reverse.each do |i|
unless db.get_first_row("select * from favorites where guid = '#{i.guid.content}'")
db.execute "insert into favorites values ('#{i.guid.content}')"
twitter.update("RT @" + i.title)
count += 1
sleep 1
end
exit if count > 5
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment