Events API Example: Publishing Events to Eventful.com - Perl Script
Thes are the general steps and the perl script written to publish events created in Convio to eventful.com. This is just an example of what can be done with the Events API.
#!/usr/bin/perl
# This gets events from a Convio-powered site using the REST API and then puts
# them on the eventful.com site.
# It selects events with a certain interest category (initially hard-coded to
# "eventful") for publishing to eventful.com.
# It uses a DBM database (id_map.pag and id_map.dir files are created) to keep
# track of the mapping of Convio event IDs to eventful event IDs.
#
# It does not currently handle removing events from eventful if they are removed
# from the Convio-powered site.
# I tried organizing all eventful events in an eventful "calendar" so that I
# could get the list of all events in that calendar to identify ones that were
# no longer in the Convio-powered site's listing. However, the "calendar"
# functionality of eventful.com does not seem to function correctly.
# It might be possible to create an eventful "venue" for the organization and
# associate all events with it. Then the venue ID could be used in the event
# search API to get all eventful events for the organization and look for ones
# that need to be removed.
#
# Before using this:
# 1) Create an account at eventful.com and request an API key. Store that in eventful_api_key below.
# 2) Store your user name and MD5 hash of your password in eventful_user_name and eventful_password_md5 below.
# 3) Create a calendar at eventful.com and store its ID in cal_id below.
# 4) Update the url_path and convio_api_key variables below for invoking the Convio Events API
# 5) Create a Convio interest category to assign to Convio events and store in eventful_interest_cat below.
# Only events with this interest are sent to the eventful site.
# 6) Install required perl libraries:
# perl -MCPAN -e 'install XML::XPath'
# perl -MCPAN -e 'install XML::XPath::XMLParser'
# perl -MCPAN -e 'install WebService::Eventful'
use XML::XPath;
use XML::XPath::XMLParser;
use WebService::Eventful;
require LWP::UserAgent;
# Base file name for Convio -> Eventful event ID mapping
my $id_map_file = "id_map";
my $debug = 0;
# Convio API parameters
my $url_path = "http://your_org_domain/site"; # Using SSL requires package Crypt:SLeay
my $convio_api_key = "your_site_api_key";
my $eventful_interest_cat = "eventful";
# eventful API parameters
my $eventful_api_key = "alphabet_soup_from_eventful";
my $eventful_user_name = "XXXXX";
my $eventful_password_md5 = "md5_hash_of_eventful_password";
my $cal_id = "C#-###-#########-#"; # ID of calendar created manually
# Handle to eventful.com API.
# Call eventfulLogin() to establish.
my $eventfulAPI;
# id_map maps Convio event ID to eventful event ID
my %id_map = ();
dbmopen (%id_map, $id_map_file, 0666) or die "Can't open ID DB file";
# Loop through all months this year
for $mon (1..12) {
postConvioEventsToEventful ("2009", $mon);
}
# Get Convio events for given year and month and add or update them in eventful.
sub postConvioEventsToEventful {
local ($year, $month) = @_;
my $uri = URI->new($url_path . "/CROrgEventAPI");
%get_events_args = (
"v", "1.0",
"api_key", $convio_api_key,
"method", "getMonthEvents",
"month", $month,
"year", $year,
"interests", $eventful_interest_cat,
);
$uri->query_form(\\%get_events_args);
$debug && print $uri . "\\n";
# Get events
my $ua = LWP::UserAgent->new;
my $response = $ua->get($uri);
if ($response->is_success) {
$debug && print $response->decoded_content . "\\n\\n";
my $xp = XML::XPath->new (xml => $response->decoded_content);
my $evList = $xp->find("/getMonthEventsResponse/event");
foreach my $event ($evList->get_nodelist) {
my $convio_id = $xp->findvalue("id", $event);
my %args = makeEventArgs ($xp->findvalue("name", $event),
$xp->findvalue("description", $event),
$xp->findvalue("eventUrl", $event),
$xp->findvalue("eventDate/startDate", $event),
$xp->findvalue("eventDate/startTime", $event),
$xp->findvalue("eventDate/endDate", $event),
$xp->findvalue("eventDate/endTime", $event),
$xp->findvalue("attendanceOption", $event));
syncEventfulEvent ($convio_id, \\%args);
}
}
else {
die $response->status_line;
}
}
# Log in to eventful.com
sub eventfulLogin {
if (!$eventfulAPI) {
$eventfulAPI = WebService::Eventful->new(app_key => $eventful_api_key);
$eventfulAPI->login(user => $eventful_user_name, password_md5 => $eventful_password_md5)
or die "Can't log in: $WebService::Eventful::errstr";
}
return $eventfulAPI;
}
# Given an eventful event ID, return the eventful event
sub getEventfulEvent {
local($eventful_id) = @_;
my $evAPI = eventfulLogin();
my $event = $evAPI->call("events/get", {id => $eventful_id})
or die "Can't get event: $WebService::Eventful::errstr";
return $event;
}
# Given a Convio event ID, find corresponding eventful event
sub findEventfulEvent {
local($id) = @_;
my $eventful_id = $id_map{$id};
print "findEventfulEvent " . $eventful_id . "\\n";
return $eventful_id && getEventfulEvent($eventful_id);
}
# Given an eventful event ID, add the event to the eventful calendar
sub addEventfulEventToCalendar {
local($eventful_id) = @_;
my $evAPI = eventfulLogin();
my $response = $evAPI->call("calendars/events/add", {calendar_id => $cal_id, event_id => $eventful_id})
or die "Can't add event to calendar: $WebService::Eventful::errstr";
}
# Given an eventful event ID and URL, add link to the event
sub addUrlToEventfulEvent {
local($eventful_id, $url) = @_;
my $evAPI = eventfulLogin();
my %args = (
"link", $url,
"id", $eventful_id,
"link_type_id", "17" # 17 = Official Site
);
my $response = $evAPI->call("events/links/new", \\%args)
or die "Can't add link to event: $WebService::Eventful::errstr";
}
# Synchronize a Convio event with an eventful event.
# If event exists in eventful, then update it, otherwise create it.
sub syncEventfulEvent {
my $convio_id = shift(@_);
my $args = shift(@_);
my %args_hash = %$args;
my $event = findEventfulEvent ($convio_id);
# Add it if not found, else update it
if (!$event) {
$event = addEventfulEvent ($convio_id, \\%args_hash);
}
else {
my %event_hash = %$event;
$args_hash{'id'} = $event_hash{'id'};
updateEventfulEvent ($convio_id, \\%args_hash);
if (!$event_hash{'calendars'}) {
addEventfulEventToCalendar ($event_hash{'id'});
}
}
}
# Builds the arguments for adding or modifying an event.
sub makeEventArgs {
local($title, $description, $url, $start_day, $start_time, $end_day, $end_time, $attendance) = @_;
$start = substr($start_day, 0, 10) . "T" . $start_time;
if ($end_day eq "") {
$end_day = $start_day;
}
$end = substr($end_day, 0, 10) . "T" . $end_time;
my $freeness = ($attendance eq 2) ? "0" : "1";
%event_args = (
"calendar_id", $cal_id,
"title", $title,
"description", $description,
"start_time", $start,
"stop_time", $end,
"all_day", "0", # not all-day
"privacy", "1", # public
"free", $freeness,
"url", $url,
);
return %event_args;
}
# Adds an event to eventful
sub addEventfulEvent {
my $convio_id = shift(@_);
my $args = shift(@_);
my %args_hash = %$args;
my $evAPI = eventfulLogin();
my $event = $evAPI->call("events/new", \\%args_hash)
or die "Can't create event: $WebService::Eventful::errstr";
my %event_hash = %$event;
my $eventful_id = $event_hash{'id'};
print "Added eventful event " . $eventful_id . " for Convio event " . $convio_id . ".\\n";
$id_map{$args_hash{'id'}} = $eventful_id;
addEventfulEventToCalendar ($eventful_id);
addUrlToEventfulEvent ($eventful_id, $args_hash{'url'});
}
# Updates existing eventful event
sub updateEventfulEvent {
my $convio_id = shift(@_);
my $args = shift(@_);
my %args_hash = %$args;
my $evAPI = eventfulLogin();
my $response = $evAPI->call("events/modify", \\%args_hash)
or die "Can't update event: $WebService::Eventful::errstr";
print "Updated eventful event " . $args_hash{'id'} . " for Convio event " . $convio_id . ".\\n";
}
sub dumpObject {
local($obj) = @_;
dumpHash(0, %$obj);
}
sub dumpHash {
local($indent_num, %hash) = @_;
$debug || return;
while (my ($k, $v) = each %hash) {
if (ref($v) eq "HASH") {
printf ("%${indent_num}skey: %s, hash:\\n", "", $k);
dumpHash($indent_num + 4, %$v);
}
else {
printf ("%${indent_num}skey: %s, value: %s.\\n", "", $k, $v);
}
}
}
Categories
- All Categories
- Shannon parent
- shannon 2
- shannon 1
- 21 Advocacy DC Users Group
- 14 BBCRM PAG Discussions
- 89 High Education Program Advisory Group (HE PAG)
- 28 Luminate CRM DC Users Group
- 8 DC Luminate CRM Users Group
- Luminate PAG
- 5.9K Blackbaud Altru®
- 58 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 409 bbcon®
- 2.1K Blackbaud CRM™ and Blackbaud Internet Solutions™
- donorCentrics®
- 1.1K Blackbaud eTapestry®
- 2.8K Blackbaud Financial Edge NXT®
- 1.1K Blackbaud Grantmaking™
- 527 Education Management Solutions for Higher Education
- 1 JustGiving® from Blackbaud®
- 4.6K Education Management Solutions for K-12 Schools
- Blackbaud Luminate Online & Blackbaud TeamRaiser
- 16.4K Blackbaud Raiser's Edge NXT®
- 4.1K SKY Developer
- 547 ResearchPoint™
- 151 Blackbaud Tuition Management™
- 61 everydayhero
- 3 Campaign Ideas
- 58 General Discussion
- 115 Blackbaud ID
- 87 K-12 Blackbaud ID
- 6 Admin Console
- 949 Organizational Best Practices
- 353 The Tap (Just for Fun)
- 235 Blackbaud Community Feedback Forum
- 55 Admissions Event Management EAP
- 18 MobilePay Terminal + BBID Canada EAP
- 36 EAP for New Email Campaigns Experience in Blackbaud Luminate Online®
- 109 EAP for 360 Student Profile in Blackbaud Student Information System
- 41 EAP for Assessment Builder in Blackbaud Learning Management System™
- 9 Technical Preview for SKY API for Blackbaud CRM™ and Blackbaud Altru®
- 55 Community Advisory Group
- 46 Blackbaud Community Ideas
- 26 Blackbaud Community Challenges
- 7 Security Testing Forum
- 3 Blackbaud Staff Discussions
- 1 Blackbaud Partners Discussions
- 1 Blackbaud Giving Search™
- 35 EAP Student Assignment Details and Assignment Center
- 39 EAP Core - Roles and Tasks
- 59 Blackbaud Community All-Stars Discussions
- 20 Blackbaud Raiser's Edge NXT® Online Giving EAP
- Diocesan Blackbaud Raiser’s Edge NXT® User’s Group
- 2 Blackbaud Consultant’s Community
- 43 End of Term Grade Entry EAP
- 92 EAP for Query in Blackbaud Raiser's Edge NXT®
- 38 Standard Reports for Blackbaud Raiser's Edge NXT® EAP
- 12 Payments Assistant for Blackbaud Financial Edge NXT® EAP
- 6 Ask an All Star (Austen Brown)
- 8 Ask an All-Star Alex Wong (Blackbaud Raiser's Edge NXT®)
- 1 Ask an All-Star Alex Wong (Blackbaud Financial Edge NXT®)
- 6 Ask an All-Star (Christine Robertson)
- 21 Ask an Expert (Anthony Gallo)
- Blackbaud Francophone Group
- 22 Ask an Expert (David Springer)
- 4 Raiser's Edge NXT PowerUp Challenge #1 (Query)
- 6 Ask an All-Star Sunshine Reinken Watson and Carlene Johnson
- 4 Raiser's Edge NXT PowerUp Challenge: Events
- 14 Ask an All-Star (Elizabeth Johnson)
- 7 Ask an Expert (Stephen Churchill)
- 2025 ARCHIVED FORUM POSTS
- 322 ARCHIVED | Financial Edge® Tips and Tricks
- 164 ARCHIVED | Raiser's Edge® Blog
- 300 ARCHIVED | Raiser's Edge® Blog
- 441 ARCHIVED | Blackbaud Altru® Tips and Tricks
- 66 ARCHIVED | Blackbaud NetCommunity™ Blog
- 211 ARCHIVED | Blackbaud Target Analytics® Tips and Tricks
- 47 Blackbaud CRM Higher Ed Product Advisory Group (HE PAG)
- Luminate CRM DC Users Group
- 225 ARCHIVED | Blackbaud eTapestry® Tips and Tricks
- 1 Blackbaud eTapestry® Know How Blog
- 19 Blackbaud CRM Product Advisory Group (BBCRM PAG)
- 1 Blackbaud K-12 Education Solutions™ Blog
- 280 ARCHIVED | Mixed Community Announcements
- 3 ARCHIVED | Blackbaud Corporations™ & Blackbaud Foundations™ Hosting Status
- 1 npEngage
- 24 ARCHIVED | K-12 Announcements
- 15 ARCHIVED | FIMS Host*Net Hosting Status
- 23 ARCHIVED | Blackbaud Outcomes & Online Applications (IGAM) Hosting Status
- 22 ARCHIVED | Blackbaud DonorCentral Hosting Status
- 14 ARCHIVED | Blackbaud Grantmaking™ UK Hosting Status
- 117 ARCHIVED | Blackbaud CRM™ and Blackbaud Internet Solutions™ Announcements
- 50 Blackbaud NetCommunity™ Blog
- 169 ARCHIVED | Blackbaud Grantmaking™ Tips and Tricks
- Advocacy DC Users Group
- 718 Community News
- Blackbaud Altru® Hosting Status
- 104 ARCHIVED | Member Spotlight
- 145 ARCHIVED | Hosting Blog
- 149 JustGiving® from Blackbaud® Blog
- 97 ARCHIVED | bbcon® Blogs
- 19 ARCHIVED | Blackbaud Luminate CRM™ Announcements
- 161 Luminate Advocacy News
- 187 Organizational Best Practices Blog
- 67 everydayhero Blog
- 52 Blackbaud SKY® Reporting Announcements
- 17 ARCHIVED | Blackbaud SKY® Reporting for K-12 Announcements
- 3 Luminate Online Product Advisory Group (LO PAG)
- 81 ARCHIVED | JustGiving® from Blackbaud® Tips and Tricks
- 1 ARCHIVED | K-12 Conference Blog
- Blackbaud Church Management™ Announcements
- ARCHIVED | Blackbaud Award Management™ and Blackbaud Stewardship Management™ Announcements
- 1 Blackbaud Peer-to-Peer Fundraising™, Powered by JustGiving® Blogs
- 39 Tips, Tricks, and Timesavers!
- 56 Blackbaud Church Management™ Resources
- 154 Blackbaud Church Management™ Announcements
- 1 ARCHIVED | Blackbaud Church Management™ Tips and Tricks
- 11 ARCHIVED | Blackbaud Higher Education Solutions™ Announcements
- 7 ARCHIVED | Blackbaud Guided Fundraising™ Blog
- 2 Blackbaud Fundraiser Performance Management™ Blog
- 9 Foundations Events and Content
- 14 ARCHIVED | Blog Posts
- 2 ARCHIVED | Blackbaud FIMS™ Announcement and Tips
- 59 Blackbaud Partner Announcements
- 10 ARCHIVED | Blackbaud Impact Edge™ EAP Blogs
- 1 Community Help Blogs
- Diocesan Blackbaud Raiser’s Edge NXT® Users' Group
- Blackbaud Consultant’s Community
- Blackbaud Francophone Group
- 1 BLOG ARCHIVE CATEGORY
- Blackbaud Community™ Discussions
- 8.3K Blackbaud Luminate Online® & Blackbaud TeamRaiser® Discussions
- 5.7K Jobs Board