Services_EVDB PHP Package

Installation

If you have the ability to install PEAR packages (type pear help to verify), installation should be as simple as:

pear install http://api.eventful.com/libs/Services_EVDB.latest.tgz

If PEAR isn't available, follow these steps to install the package:

  1. Download the latest release of Services_EVDB.
  2. Unzip the archive into a temporary directory: tar -xzvf Services_EVDB.latest.tgz
  3. Copy the EVDB.php file from the temporary directory into a Services directory under your PHP library path.
  4. Copy the get_event.php example script from the temporary directory into a directory along with your other PHP scripts.

Description

The EVDB API allows you to build tools and applications that interact with EVDB, the Events & Venues Database. This package provides a PHP interface to that API, including the digest-based authentication infrastructure.

See the API documentation at http://api.eventful.com for details.

Synopsis

require 'Services/EVDB.php';

// Enter your application key here. (See http://api.eventful.com/keys/)
$app_key = 'change-this-application-key';

$evdb = &new Services_EVDB($app_key);

// Authentication is required for some API methods.
$user     = $_REQUEST['user'];
$password = $_REQUEST['password'];

if ($user and $password)
{
  $l = $evdb->login($user, $password);
  
  if ( PEAR::isError($l) )
  {
      print("Can't log in: " . $l->getMessage() . "\n");
  }
}

// All method calls other than login() go through call().
$args = array(
  'id' => $_REQUEST['id'],
);
$event = $evdb->call('events/get', $args);

if ( PEAR::isError($event) )
{
    print("An error occurred: " . $event->getMessage() . "\n");
    print_r( $evdb );
}

// The return value from a call is an XML_Unserializer data structure.
print_r( $event );

Methods

Services_EVDB()

Creates a new Services_EVDB object. Requires a valid app_key as provided by EVDB.

login()

Authenticates the given user and retrieves an authentication key from the EVDB API server. The authentication key is automatically passed to the server with each subsequent call().

call()

Calls the specified method with the given arguments and any previous authentication information (including app_key). Returns a data structure processed through XML_Unserializer.