| Path: | lib/eventful/api.rb |
| Last Update: | Mon May 14 17:15:22 -0700 2007 |
A library for working with the Eventful API. Simple programmatic access to Eventful‘s database of events, venues, performers and speakers, groups, calendars, and users.
See api.eventful.com for more information about the Eventful API and the available API methods.
require 'rubygems'
require 'eventful/api'
begin
# Start an API session with a username and password
eventful = Eventful::API.new 'application_key',
:user => 'username',
:password => 'password'
# Lookup an event by its unique id
event = eventful.call 'events/get',
:id => 'E0-001-001042544-7'
puts "Event Title: #{event['title']}"
# Get information about that event's venue
venue = eventful.call 'venues/get',
:id => event['venue_id']
puts "Venue: #{venue['name']}"
rescue Eventful::APIError => e
puts "There was a problem with the API: #{e}"
end
require 'rubygems'
require 'eventful/api'
# First, create our Eventful::API object
eventful = Eventful::API.new 'application_key'
loop do
# Ask the user what and where to search
puts "Search where? (Ex: San Diego)"
print "? "
location = gets.chomp
puts "Search for what (Ex: music)"
print "? "
query = gets.chomp
# This is the cool part!
results = eventful.call 'events/search',
:keywords => query,
:location => location,
:page_size => 5
# If we couldn't find anything, ask the user again
if results['events'].nil? then
puts
puts "Hmm. I couldn't find anything. Sorry."
puts
next
end
# Output the results
results['events']['event'].each do |event|
puts
puts "http://eventful.com/events/" + event['id']
puts event['title']
puts " at " + event['venue_name']
puts " on " + Time.parse(event['start_time']).strftime("%a, %b %d, %I:%M %p") if event['start_time']
end
puts
end
Use of the Eventful API requires an application key (see api.eventful.com/keys for more information).
Version 2.0 of this library includes some significant changes which may not be backwards compatible. Specifically:
Most importantly, the library now uses YAML as its data exchange format instead of XML, and the objects returned from a call can be used like hashes instead of REXML objects.
| Status: | Stable |
| Version: | 2.2.0 |
| Date: | 2007-03-24 |
| Current Author: | Paul Knight (paul@eventful.com) |
| Previous Authors: | Joe Auricchio |
| Copyright: | Copyright (C) 2005-2007 Eventful Inc. |
| License: | This code is distributed under the same terms as Ruby itself (see www.ruby-lang.org/en/LICENSE.txt) |