NAME
Catalyst::Model::EVDB - EVDB model class for Catalyst
SYNOPSIS
# Use the Catalyst helper
script/myapp_create.pl model EVDB EVDB xxxxxxxxxxxxxxxx
# lib/MyApp/Model/EVDB.pm
package MyApp::Model::EVDB;
use base qw/Catalyst::Model::EVDB/;
__PACKAGE__->config(
app_key => 'xxxxxxxxxxxxxxxx',
);
1;
# In a controller action
my %args = (
location => 'Gainesville, FL',
keywords => 'tag:music',
);
my $evdb = $c->model('EVDB');
my $results = $evdb->call('events/search', \%args)
or die 'Error searching for events: ' . $evdb->errstr;
DESCRIPTION
This is the EVDB::API model class for Catalyst. EVDB::API is a Perl
interface to EVDB, the Events and Venues Database.
Please note that EVDB API methods require an application key.
For more information on EVDB, or to obtain an application key, see
.
METHODS
new
Create a new EVDB model component, using "app_key" as specified in your
configuration.
errstr
Return the EVDB API error message.
login
Login using the specified username and password. For example:
# In a controller action (don't forget validation!)
my $username = $c->req->param('username');
my $password = $c->req->param('password');
my $evdb = $c->model('EVDB');
$evdb->login(username => $username, password => $password)
or die 'Error logging in: ' . $evdb->errstr;
Alternatively, you can set a username and password in the configuration
for your model class. They will be used when this method is called
without arguments. For example:
# In your model class
__PACKAGE__->config(
app_key => 'xxxxxxxxxxxxxxxx',
username => 'danieltwc',
password => 'secret',
);
# In a controller action
my $evdb = $c->model('EVDB');
$evdb->login or die 'Error logging in: ' . $evdb->errstr;
# Call an EVDB method which requires authentication
my %args = (
title => 'Lamb',
start_time => '2006-03-18T21:00:00',
tags => 'music',
venue_id => 'V0-001-000160549-4',
);
my $response = $evdb->call('events/new', \%args);
This method also supports passwords which have already been hashed using
MD5. Use the "password_md5" key instead of "password" when calling the
method or in your configuration.
SEE ALSO
* Catalyst::Helper::Model::EVDB
* Catalyst
* EVDB::API
AUTHOR
Daniel Westermann-Clark
ACKNOWLEDGMENTS
* Brian Cassidy, for clever "new" code
LICENSE
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.