Buy Now
Sign in

FAQ search

How to post information from a Chronoform to ZoHo

Details
Published: Monday, 30 November -0001 00:00

This FAQ is taken from a forum post by lowrykun.

I looked in the forum and didn't see a working example of how to post information from a Chronoform to ZoHo. I came up with a really simple way of doing it using the new Authentication Token.
On the OnSubmit Event add a Custom Code action.
<?php
//Get your auth code through the ZoHo
$auth = 'YOUR AUTH CODE';

// This is a very basic lead. 
// See https://zohocrmapi.wiki.zoho.com/insertRecords-Method.html#Sample_Lead_XMLDATA
$xml = '<Leads>
<row no="1">
<FL val="Lead Source">Website</FL>
<FL val="First Name">'.$form->data['first_name'].'</FL>
<FL val="Last Name">'.$form->data['last_name'].'</FL>
<FL val="Email">'.$form->data['email'].'</FL>
</row>
</Leads>';

//Initialize connection
$ch = curl_init('https://crm.zoho.com/crm/private/xml/Leads/insertRecords');
//standard i/o streams
curl_setopt($ch, CURLOPT_VERBOSE, 1);
// Turn off the server and peer verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
//Set to return data to string ($response)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);//Regular post
//Set post fields
$query = "authtoken={$auth}&scope=crmapi&xmlData={$xml}";
// Set the request as a POST FIELD for curl.
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
//Execute cUrl session
$response = curl_exec($ch);
curl_close($ch);
?>
That's it! With a valid token this should submit the contact's First Name, Last Name, Email, and Lead Source.

You could also build this with my {rokbox text=|cURL [GH] action| size=|1000,600| }http://greyhead.net/how-to-docs/cfv4-curl-gh-action{/rokbox} which allows you to set CURLOPTS