How can import contact address/address book

Do you need to import your contact address or addressbook? Rapleaf Address Book API kit allows you to Rapleaf Address Book API through direct PHP function calls. The Address Book API allows for a user to import their email contact list (from Gmail, Yahoo!, AOL, and Hotmail) into any site. This API is used on dozens of sites and applications, and is a way for users to invite friends to a site, share content with people in their address book, and import their social relationships.

  • rapleaf_abook.php – the library file that you need to put on your server and include.
  • sample.php – a sample application to help get you started. It simply displays your contact list.

How you can use it:

Step 1: Include the library
<? require_once ‘rapleaf_abook.php’; ?>
Step 2: Initialize an address book object. You can find your API key here.
<? $abook = new RapleafAbook($api_key);?>
Step 3: Query the API for the contact list. You need to get the user’s email address and password through a form; see sample.php for an example.
<? $result = $abook->getData($email, $password);?>

The returned result has the following structure:

	<? $result = (
		'status'   => '200',  # HTTP status code returned by the server
		'error'    => '',     # error message if there are any
		'contacts' => (       # contact list
		               ([name]=>'dummy',  [email]=>''),
		               ([name]=>'dummy2', [email]=>''),
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') { # OK
		$contacts = $result['contacts'];
		foreach ($contacts as $contact) {
			$html.= htmlentities($contact['name'].' <'.$contact['email'].'>');
			$html.='<br />';
	} else {
		$html = $result['status'].': '.$result['error'];

	echo $html;

You can find demo here: Demo
You can download sample code from here: Download


One Response

  1. Is this script open source?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: