public
Description: Read an RSS feed (even HTTPS with authentication) and rebroadcast it to a Twitter account.
Clone URL: git://github.com/trak3r/rss2twitter.git
trak3r (author)
Wed Apr 30 07:07:04 -0700 2008
commit  149c7f9389a7c6d10d589d81409532f7f1212a10
tree    ff8d54d85e0b077ff068d6c2da8915d18ec43a78
parent  48eef21d8beec7ff101790ea83422f6a612b688b
rss2twitter / tweets.rb
100644 21 lines (17 sloc) 0.516 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'rubygems'
require 'twitter'
 
require 'config'
require 'database'
require 'feed'
 
def parse_and_push
  settings = Settings.new
 
  for item in process(settings.rss_url)
    Item.transaction do
      unless existing_item = Item.find(:all, :conditions => ["link=?", item.link]).first
        twitter ||= Twitter::Base.new(settings.twitter_email, settings.twitter_password)
        new_item = Item.create(:title => item.title, :link => item.link)
        twitter.post(new_item.to_s)
      end
    end
  end
end