Back to Top

How to create zoho leads using PHP?

To create zoho leads using PHP

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.

/* Constants Declaration */
define("TARGETURL", "https://crm.zoho.com/crm/private/xml/Leads/insertRecords");
define("AUTHTOKEN", "");// Replace with your desired token
define("SCOPE", "crmapi");

// Here replace the form value
$xmldata='
            
                Website
                Web Page - Quote Form
                127.0.0.1
                Bhumi
                Shah
                [email protected]
                test description
            
           ';

$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_HEADER      ,0);  // DO NOT RETURN HTTP HEADERS
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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to use Replace function in MySQL

Posted on 7 years ago

Bhumi

What Is Making People Insane for Cake PHP?

Posted on 6 years ago

Bhumi

How to use CSS3 Object-fit

Posted on 4 years ago

Bhumi

How To Store Binary Data in PHP

Posted on 7 years ago

Bhumi

The Reader’s Poll – June 2015

Posted on 4 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 4 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 5 years ago

Bhumi