A usefull PHP class to import Zyb.com contacts
Posted on April 15, 2010I have written a class to simplify the import of contacts from http://zyb.com service. Zyb.com offers its users to upload their mobile phone contacts via mobile sync.
To use this class, you need to have your zyb.com user id and a private key. It can be obtained by logging into zyb.com and going to “settings” menu.
Below is the coding of class “ZYBImport.inc.php”
<?php
/*
This class can pull the contacts from Zyb.com account.
It needs a Zyb.com user name and private key. It can be obtained by loging into zyb.com account
and going to settings. Zyb.com returns lots of information, by little modification in this class you can pull all.
Written By: Arfeen
*/
class ZYBImport {
function __construct($ZybUser,$ZybKey){
$this->APIPath = "http://zyb.com/".$ZybUser."/contacts.json?key=".$ZybKey;
}
function GetZybContacts(){
$RawContacts = file_get_contents($this->APIPath);
$Contacts = json_decode($RawContacts, true); // It returns contacts in JSON format.
return $Contacts;
}
};
?>
To use this class, here’s an example. Below is the code of “example.php”
<?php
// example that pull the contacts details from zyb.com account
include "ZybImport.inc.php";
$Zyb = new ZYBImport("ZYB_UserName","ZYB_KEY") ; // Get your username and key from settings page in zyb.com
$Contacts = $Zyb->GetZybContacts();
for($nIndex=0;$nIndex
print "
Full Name : " . $Contacts[$nIndex]['Name'];
print "
Phone Number: " . $Contacts[$nIndex]['Phone'];
}
exit;
?>