Today I am going to explain how to create Zoho leads from PHP.
Zoho provides online lead management system.Zoho leads take details of company, person and business opportunity. Many companies are using Zoho for managing leads for their company.
In most of the cases, websites are using contact or inquiry form for project leads. So to pass data directly to Zoho when someone submit a form from your website following code will be useful.
Also Read: SESSION SAVE PATH in PHP
The following code will insert data into Zoho using auth token. Here you need to pass data into XML format
and with the use of CURL request, you can pass data to target URL which will store your information.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /* Constants Declaration */ define("TARGETURL", "https://crm.zoho.com/crm/private/xml/Leads/insertRecords"); define("SCOPE", "crmapi"); // Here replace the form value $xmldata='<Leads> <row no="1"> <FL val="Lead Source">Website</FL> <FL val="Filled Form">Web Page - Quote Form</FL> <FL val="IP Address">127.0.0.1</FL> <FL val="First Name">Bhumi</FL> <FL val="Last Name">Shah</FL> <FL val="Email">info@creativedev.in</FL> <FL val="Description">test description</FL> </row> </Leads>'; $fields = array( 'newFormat'=>1, 'authtoken'=>AUTHTOKEN, 'scope'=>SCOPE, 'xmlData'=>$xmldata ); $fields_string = NULL; foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } $fields_string = rtrim($fields_string,'&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, TARGETURL); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string); curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL $result=curl_exec($ch); curl_close($ch); |
Here, I have passed data in post form in cURL. POST data will send XML data, auth token and scope.
Hope this article helps someone.As always, thanks for reading. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.
Comments (1)