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";

//================= start curl ===================
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
//================= end curl ===================
echo '<pre>';

  1. Rupam says:


    this is a helpful post for us.but i have one scenario…
    when some one create Leads in Zoho CRM then the same record with same value creates in MySQL database…. so how to achieve this functionality???

    Thanks & Regards,
    Zoho CRM Fun…!!!

    • vibhajadwani says:

      Hi Rupam,

      For that you can create one php script where you will fetch lead data and add it in your MySql. Now add this page in CronJob of your server. You can set cronjob timer of 30mins, so after each 30min it will sync all leads from ZOHO.


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