Skip to content

Instantly share code, notes, and snippets.

@pauldix
Created June 19, 2009 15:11
Show Gist options
  • Save pauldix/132671 to your computer and use it in GitHub Desktop.
Save pauldix/132671 to your computer and use it in GitHub Desktop.
# this shows how to use the update functionality for a single feed with feedzirra
require 'rubygems'
require 'feedzirra'
# I'm using Atom here, but it could be anything. You don't need to know ahead of time.
# It will parse out to the correct format when it updates.
feed_to_update = Feedzirra::Parser::Atom.new
feed_to_udpate.feed_url = some_stored_feed_url
feed_to_update.etag = some_stored_feed_etag
feed_to_update.last_modified = some_stored_feed_last_modified
last_entry = Feedzirra::Parser::AtomEntry.new
last_entry.url = the_url_of_the_last_entry_for_a_feed
feed_to_update.entries = [last_entry]
updated_feed = Feedzirra::Feed.update(feed_to_update)
updated_feed.updated? # => nil if there is nothing new
updated_feed.new_entries # => [] if nothing new otherwise a collection of feedzirra entries
updated_feed.etag # => same as before if nothing new. although could change with comments added to entries.
updated_feed.last_modified # => same as before if nothing new. although could change with comments added to entries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment