Rapleaf Perl API Kit

This is an API Kit to you integrate Rapleaf with your Perl projects. You will not have to worry about calling the Rapleaf API directly, instead you can just use native Perl function calls.

Download

The most convenient way of getting the API Kit is to check out the lastest version using Subversion:

$ svn checkout http://svn.rapleaf.com/public/perl-api-kit/trunk rapleaf

Later, you can get the latest version of this API Kit by returning to that directory and issuing "svn update".

Use

The simple steps below are taken from examples.pl.

First, include the Rapleaf library:

require "rapleaf.pl";

Second, set necessary variables for using the API. Make sure to replace 'apikey' with your API Key from the Developer Resources Page. The second function call is optional and sets the url of the Rapleaf API. You should use 'http://rapleaf.com'.

&rapleaf_set_api_key ('apikey');
&rapleaf_set_base_url ('http://rapleaf.com');

Third, either lookup a profile or report a rating by calling the appropriate function:

# lookup a profile by email
my %params = ('email', 'dummy@rapleaf.com');
my $response = &rapleaf_lookup (\%params);

or

# rate by email
my %params = ('rating'        => 'positive',
	      'relationship'  => 'Friend',
	      'comment'       => 'the_comment',
	      'target_email'  => 'dummy@rapleaf.com',
	      'rater_email'   => 'dummy2@rapleaf.com',
	      'rater_verified'=> 0);
my $response = &rapleaf_report_rating (\%params);

Finally, check the response using something like this:

if ($response->{status} eq 'failed') {
  print "Request failed because: ".$response->{reason}."\n";
} else {
  if ($response->{profile_stats} eq 'Profile not found.') {
    print $response->{profile_stats}."\n";
  } else {
    print "The Rapleaf score is: ".$response->{profile_stats}->{score}."\n";
  }
}

For details about what is contained in the $response hash, look at the 'Response' section in any of the API methods in the API Documentation.