Rapleaf PHP API Kit

This is an API Kit to you integrate Rapleaf with your PHP projects. You will not have to worry about calling the Rapleaf API directly, instead you can just use native PHP 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/php-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

See the examples.php file included in the repository for actual examples or follow the simple steps below.

First, include the Rapleaf library:

require_once 'rapleaf.php';

Second, instanciate a new Rapleaf object. Make sure to replace 'apikey' with your API Key from the Developer Resources Page. The second argument is optional and is the url with which the Rapleaf object will look for the API. You should use 'http://rapleaf.com'.

$rapleaf = new Rapleaf('apikey', 'http://rapleaf.com');

Third, either look up or report a rating by calling the appropriate function (see more examples in examples.php):

$responseObject = $rapleaf->lookup(array('email'=>'dummy@rapleaf.com'));

or

$responseObject = $rapleaf->rate(array(
                             'rating'       => 'positive',
			     'relationship' => 'Friend',
			     'comment'      => 'the_comment',
			     'target_email' => 'person_being_rated_email',
			     'rater_email'  => 'raters_email',
			     'rater_verified' => 0));

Finally, check the response using something like this:

if (is_null($responseObject))
  echo "Connection failed.\n";
else if ($responseObject->failed())
  echo $responseObject->reason."\n";
else {
  //if profile_stats is set that means this is a "profile not found" response
  if (isset($responseObject->profile_stats))
    echo $responseObject->profile_stats."\n";
  else
    echo "Rating is " . $responseObject->score."\n";
}

For details about what is contained in the $responseObject, look at examples.php and the 'Response' section in any of the API methods in the API Documentation.