Zoho Crm

This is our file, which will be used for api call & authentication

zoho.php file

class zoho{

public  $username;
public  $password;

public function getAuth()
$param = “SCOPE=ZohoCRM/crmapi&EMAIL_ID=”.$this->username.”&PASSWORD=”.$this->password;
$ch = curl_init(“https://accounts.zoho.com/apiauthtoken/nb/create&#8221;);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
$result = curl_exec($ch);

$anArray     = explode(“\n”,$result);
$authToken  = explode(“=”,$anArray[‘2’]);
$cmp = strcmp($authToken[‘0’],”AUTHTOKEN”);
echo $anArray[‘2’].””; if ($cmp == 0)
return $authToken[‘1′];

public function postData($auth, $firstName,$lastName, $email,$address,$phone,$fax,$mobile)
$xml =’
<row no=”1″>
<fl val=”First Name”>’.$firstName.'</fl>
<fl val=”Last Name”>’.$lastName.'</fl>
<fl val=”Email”>’.$email.'</fl>
<fl val=”Department”>’.$address.'</fl>
<fl val=”Phone”>’.$phone.'</fl>
<fl val=”Fax”>’.$fax.'</fl>
<fl val=”Mobile”>’.$mobile.'</fl>

$url =”https://crm.zoho.com/crm/private/xml/Contacts/insertRecords&#8221;;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
$response = curl_exec($ch);
echo $response;




Now lets call the file


$zoho = new zoho();
$auth = $zoho->getAuth();
$result = $zoho->postData($auth, ‘Mamnun’,’Rashid’, ‘mamun@naz.com’,’Address’,’0170000′,’Fax-11111′,’M-0171111′);


its simple


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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