Syndic8 (Class)

In: syndic8.rb  (CVS)
Parent: Object

Syndic8 - Ruby bindings for the Syndic8 (syndic8.com/) XML-RPC interface.

Basic Usage:

  require 'syndic8'

  # simple query
  s = Syndic8.new
  feeds = s.find('cooking')
  feeds.each { |feed| p feed }

  # set number of results and fields returned
  # (both can affect size and duration of query)
  s.max_results = 10
  s.keys -= ['description']

  feeds = s.find('linux')
  feeds.each { |feed| p feed }

Managing a Subscription List:

  require 'syndic8'

  # log in to syndic8 with user "joebob" and password "p455w3rd"
  s = Syndic8.new('joebob', 'p455w3rd')

  # create a new private list
  list_id = s.create_subscription_list("Joebob's Links")

  # subscribe to pablotron.org on your subscription list
  s.subscribe_feed(list_id, 'http://pablotron.org/rss/', false)

  # subscribe to NIF Health category on list
  s.subscribe_category(list_id, 'NIF', 'Health')

Using the Weblog Ping Service:

  s = Syndic8.new
  s.ping('Pablotron', 'http://pablotron.org/')

Constants

VERSION = '0.2.0'

Attributes

keys  [RW] 
max_results  [RW] 

Classes and Modules

Class Syndic8::Error

Public Class methods

Create a new Syndic8 object. Note: the username and password are optional, and only used for certain (explicitly labeled) methods.

Raises Syndic8::Error on error.

Example:

  # connect to syndic8
  s = Syndic8.new

  # connect to syndic8 with user 'joe' and password 'bob'
  s = Syndic8.new('joe', 'bob')

Public Instance methods

Returns the immediate child categories of the given category.

Raises Syndic8::Error on error.

Example:

  kids = s.category_children(scheme, category)

Returns the top-level category names for the given scheme.

Raises Syndic8::Error on error.

Example:

  roots = s.category_roots

Returns an array of the supported category schemes.

Raises Syndic8::Error on error.

Example:

  schemes = s.category_schemes

Returns the set of known categories for the given category scheme.

Raises Syndic8::Error on error.

Example:

  trees = s.category_trees

Accepts a start date, and optionally an end date, an array of fields to check, and a list of fields to return. It checks the change log for the feeds, and returns the requested feed fields for each feed where a requested field has changed.

If end_date is unspecified or nil, it defaults to today. check_fields is nil or unspecified, it defaults to all fields. If ret_fields is nil or unspecified it defaults to @keys.

Raises Syndic8::Error on error.

Example:

  # return a list of feeds that have changed since December 1st,
  # 2003
  changed_ary = s.changed_feeds(Time::mktime(2003, 12, 1))

  # Return a list of URLs of feeds that have changed descriptions
  # since the beginning of the month
  t = Time.now
  changed = s.changed_feeds(Time::mktime(t.year, t.month), Time::now,
                            ['description'], ['siteurl'])

Creates a new subscription list for the given user, and returns the List identifier of the list.

Note: You must be logged in and using the PersonalList option in order to use this method.

Raises Syndic8::Error on error.

Examples:

  # create a new private list called 'foo-private'
  id = s.create_subscription_list('foo-private')

  # create a new public list called 'Cool_Sites'
  id = s.create_subscription_list('Cool_Sites', true)

Creates a new subscription list for the given user. The list will contain feeds referenced from the given HTML page. If AutoSuggest is given, unknown feeds will be automatically suggested as new feeds.

Returns an array of hashes with ID, feed ID, and status code.

Note: You must be logged in and using the PersonalList option in order to use this method.

Raises Syndic8::Error on error.

Example:

  ary = s.create_subscription_list_from_html('pablotron_feeds', true, 'http://pablotron.org/', true)

Creates a new subscription list for the given user. The list will contain the feeds from the given OPML. If AutoSuggest is given, unknown feeds will be automatically suggested as new feeds.

Returns an array of hashes, each with ID (from OPML), feed ID, and status code.

Note: You must be logged in and using the PersonalList option in order to use this method.

Raises Syndic8::Error on error.

Example:

  ary = s.create_subscription_list_from_opml('raggle feeds', true, 'http://pablotron.org/download/feeds.opml', true)

Ceates a new Syndic8 user. Returns true on success or false on failure.

Note: You must be logged in and have the CreateUser option in order to use this method.

Raises Syndic8::Error on error.

Example:

  success = s.create_user('mini-pabs', 'Mini', 'Pabs', 'minipabs@pablotron.org', '', 'PersonalList', true, 'http://mini.pablotron.org/', '', '')

Deletes the indicated subscription list. All feeds and categories will be removed from the list. Returns true on success or false on failure.

Note: You must be logged in and using the PersonalList option in order to use this method.

Raises Syndic8::Error on error.

Example:

  # create and then immediately delete list
  id = s.create_subscription_list('Cool_Sites', true)
  s.delete_subscription_list(id)

Sends notification of a change at the given site.

Raises Syndic8::Error on error.

Example:

  s.ping('Pablotron', 'http://pablotron.org/', 0, 'http://pablotron.org/rss/')

Returns the number of feeds that are in the Syndic8 feed table.

Raises Syndic8::Error on error.

Aliases:

  Syndic8#size

Example:

  num_feeds = s.size

Returns an array of arrays containing the requested fields for each feed ID. Field names and interpretations are subject to change.

Raises Syndic8::Error on error.

Example:

  # get info for given feed IDs
  info_ary = feed_info(ids)

Returns an array of feeds IDs in the given category within the given scheme.

Raises Syndic8::Error on error.

Example:

  # get a list of feeds IDs in the NIF Health category
  ids = s.feeds_in_category('NIF', 'Health')

Get a list of fields returned by Syndic8.

Raises Syndic8::Error on error.

Example:

  fields = s.fields

Very simple find method, not included in the Syndic8 API. Roughly equivalent to calling Syndic8#find_feeds, and passing the result to Syndic8#get_feed_info.

Raises Syndic8::Error on error.

Example:

  # return first Syndic8#max_results feeds on cooking
  feeds_ary = s.find('cooking')

Returna list of feeds IDs matching a given search string, sorting by sort_field.

Raises Syndic8::Error on error.

Example:

  ids = s.find_feeds 'poop'

Matches the given pattern against against the SiteURL field of every feed, and returns the IDs of matching feeds.

Raises Syndic8::Error on error.

Example:

  ids = s.find_sites 'reader.com'

Matches the given pattern against all text fields of the user list, and returns user IDs of matching users.

Raises Syndic8::Error on error.

Example:

  user_ids = s.find_users 'pabs'

Returns the highest assigned feed ID.

Raises Syndic8::Error on error.

Example:

  last_id = s.last_feed

Returns an array of hashes. Each structure represents a single type of feed license.

Raises Syndic8::Error on error.

Example:

  licenses = s.licenses

Returns an array of the supported location schemes.

Raises Syndic8::Error on error.

Example:

  loc_schemes = s.location_schemes

Sends notification of a change at the given site.

Raises Syndic8::Error on error.

Example:

  s.ping('Pablotron', 'http://pablotron.org/')

Takes the given feed field, relationship (<, >, <=. >=, !=, =, like, or regexp), and feed value and returns the list of feeds with a matching value in the field.

Raises Syndic8::Error on error.

Example:

  feed_ids = s.query_feeds('description', 'regexp', 'poop')

Sets the feed’s category within the given scheme.

Note: You must be logged in to use this method, and your account must have the Categorizer role.

Raises Syndic8::Error on error.

Example:

  s.set_feed_category(id, 'Syndic8', 'Culture')

Sets the feed’s location within the given location scheme.

Note: You must be logged in to use this method, and your account must have the Categorizer role.

Raises Syndic8::Error on error.

Example:

  s.set_feed_location(id, 'Geo-IP', 'asdF')

Changes values stored for a list. The new_values hash argument must contain new values for the items (name, public, etc.)

Note: You must be logged in and using the PersonalList option in order to use this method.

Raises Syndic8::Error on error.

Example:

  # create a list 'Cool_Sites', then rename it to 'Dumb_Sites'
  id = s.create_subscription_list('Cool_Sites', true)
  s.set_subscription_list_info(id, {'name' => 'Dumb_Sites'}

Sets a user’s location to the given value.

Note: You must be logged in to use this method, and your account must have the Editor role.

Raises Syndic8::Error on error.

Example:

  s.set_user_location(user_id, 'Kentucky, USA')
size()

Alias for feed_count

Returns a hash of valid feed states and descriptions.

Raises Syndic8::Error on error.

Example:

  feed_states = s.states

Subscribes the user’s given list (0 is the public list) to the given category of feeds.

Note: You must be logged in and using the PersonalList option in order to use this method.

Raises Syndic8::Error on error.

Example:

  # create a new Gadgets list and subscribe to the
  # NIF PDA list
  list_id = s.create_subscription_list('Gadgets', true)
  s.subscribe_category(list_id, 'NIF', 'PDA')

Subscribes the user’s given list (0 is the public list) to the given feed. The user must have the PersonalList option. If a DataURL is given and AutoSuggest is true and the feed is not known, it will be suggested as if by entered by user ID.

Note: You must be logged in and using the PersonalList option in order to use this method.

Raises Syndic8::Error on error.

Example:

  # subscribe to pablotron.org on the public list, and suggest it if
  # Syndic8 doesn't already know about it
  s.subscribe_feed(0, 'http://pablotron.org/rss/', true)

Returns the set of feeds that the user is subscribed to both directly (as feeds) and indirectly (via a category of feeds).

Note: You must be logged in and using the PersonalList option in order to use this method.

Raises Syndic8::Error on error.

Example:

  feeds = s.subscribed(list_id)

Returns the set of categories that the user is subscribed to, as an array of hashes containing schemes and categories.

Note: You must be logged in and using the PersonalList option in order to use this method.

Raises Syndic8::Error on error.

Example:

  cats = s.subscribed_categories(list_id)

Returns the list of subscription lists for the given user. Each hash includes the list id, name, and status (public or private).

Note: You must be logged in and using the PersonalList option in order to use this method.

Raises Syndic8::Error on error.

Example:

  listss = s.subscribion_lists(list_id)

Checks to see if data_url is that of a known feed. If it is not, the feed is entered as a new feed. In either case, a feed ID is returned.

Note: You must be logged in to use this method.

Raises Syndic8::Error on error.

Example:

  s.suggest_data_url('http://pablotron.org/rss/')

Checks to see if site_url is that of a known feed. If it is not, the feed is entered as a new feed. In either case, a feed ID is returned.

Note: You must be logged in to use this method.

Raises Syndic8::Error on error.

Example:

  s.suggest_site_url('http://pablotron.org/')

Returns a hash of of toolkits known to Syndic8.

Raises Syndic8::Error on error.

Example:

  toolkits = s.toolkits

Unsubscribes the user from the given category of feeds within the list.

Note: You must be logged in and using the PersonalList option in order to use this method.

Raises Syndic8::Error on error.

Example:

  s.unsubscribe_category(0, 'NIF', 'Health')

Unsubscribes the user from the given feed within the list.

Note: You must be logged in and using the PersonalList option in order to use this method.

Raises Syndic8::Error on error.

Example:

  s.unsubscribe_feed(0, feed_id)

Accepts the UserID of a known Syndic8 user and returns a structure containing all of the information from the users table. Field names and interpretations are subject to change.

Raises Syndic8::Error on error.

Example:

  info = s.user_info('pabs')

[Validate]