<< Main

Rapleaf Address Book API Kit - Perl

This helper kit allows you to use the Rapleaf Address Book API through direct Perl function calls. It gets the XML response from the Rapleaf server and returns a corresponding Perl structure.

Contents

Usage

Step 1: Include the library

	use Rapleaf; 

Step 2: Query the API for the contact list. You need to get the user's email address and password through a form; see sample.pl for an example.

	my %result = %{ Rapleaf::getData(param('email'), param('pass'), param('api_key')) }; 

The returned result has the following structure:

 	$result = {
		'status' => '200', # HTTP status code returned by the server
		'error'    => '',  # error message if there are any
		'contact' => {
			 'Dummy1' => {
					'email' => 'dummy1@rapleaf.com'
			 },
			 'Dummy2' => {
					'email' => 'dummy2@rapleaf.com'
			 },
			 ...
		}
 	};
 

You should check the status before attempting to process the contact list. The following example lists the contacts on success, prints the error message otherwise.

	$html = '';
	if ($result{'status'} == 200) {
		my $contacts = $result{'contact'};
		foreach my $contact (keys %$contacts ) {
			$html.= encode_entities($contact.' <'.$contacts->{$contact}->{'email'}.'>');
			$html.='<br />';
		}
	} else {
		$html .= $result{'status'}.': '.$result{'error'};
	}
	
	print $html;
 

Demo

Download