Posts Tagged ‘zoho’

ZOHO CRM API – Insert Attachment

Posted: August 29, 2012 in PHP
Tags: , ,

<?
$recordId = '634551000000065001';
/*
When you add any new lead in response you will get record id which you can further use for attachments. Below is the response from curl:
response uri="/crm/private/xml/Leads/insertRecords"><result><message>Record(s) added successfully</message><recorddetail><FL val="Id">634551000000065001</FL><FL val="Created Time">2012-08-28 13:37:17</FL><FL val="Modified Time">2012-08-28 13:37:17</FL><FL val="Created By"><![CDATA[Vibha]]></FL><FL val="Modified By"><![CDATA[Vibha]]></FL></recorddetail></result></response>
preg_match('/\<FL val="Id"\>(\d+)\<\/FL\>/', $result, $matches, PREG_OFFSET_CAPTURE, 3);
$recordId = $matches[1][0];
*/
$content = '@D:\wamp\www\zoho\my-attach.jpg';
$url = "https://crm.zoho.com/crm/private/xml/Leads/uploadFile?authtoken=".ZOHO_TOKEN."&scope=crmapi";
$post=array("id"=>$recordId,"content"=>$content);

//================= start curl ===================
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
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,$post);
$result = curl_exec($ch);
curl_close($ch);
//================= end curl ===================
echo '<pre>';
print_r($result);
exit;
?>

ZOHO CRM API – Insert Lead

Posted: August 29, 2012 in PHP
Tags: , ,

<?
$xmlData = '<Leads>
<row no="1">
<FL val="Lead Owner">'.$email.'</FL>
<FL val="First Name">'.$firstName.'</FL>
<FL val="Last Name">'.$lastName.'</FL>
<FL val="Email">'.$email.'</FL>
<FL val="Phone">'.$phone.'</FL>
<FL val="Description">Insert ZOHO Lead</FL>
</row>
</Leads>';
$url = "https://crm.zoho.com/crm/private/xml/Leads/insertRecords?authtoken=".ZOHO_TOKEN."&scope=crmapi";
$post=array("newFormat"=>'1',"xmlData"=>$xmlData);
//================= start curl ===================
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
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,$post);
$result = curl_exec($ch);
curl_close($ch);
//================= end curl ===================
echo '<pre>';
print_r($result);
exit;
?>