PHP cURL insert not working
Hello Everyone,
I was trying the insert example. Code is not inserting the lead into the zoho crm and also not giving any error. Can anyone please help.
Thanks in advance.
Here is the code - what's wrong in there?
- <?php
- //Initialize connection
- $ch = curl_init('https://crm.zoho.com/crm/private/xml/Leads/insertRecords?');
- curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);// Turn off the server and peer verification
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//Set to return data to string ($response)
- curl_setopt($ch, CURLOPT_POST, 1);//Regular post
- //Set post fields
- //this script is being proccessed by a form so I also put all of my $_POST['name'] variable here to be
- //used in the $xmlData variable below
- $authtoken = "...xxx...";
- $xmlData = "<Leads><row%20no=\'1\'><FL%20val=\'Company\'>Neo%20Group</FL><FL%20val=\'First%20Name\'>Praveen</FL><FL%20val=\'Last%20Name\'>Gupta</FL><FL%20val=\'Email\'>praveen@neogroup.com</FL><FL%20val=\'Lead%20Source\'>GSRM%20Website</FL></row></Leads>";
- $query = "newFormat=1&authtoken={$authtoken}&scope=crmapi&xmlData={$xmlData}";
- curl_setopt($ch, CURLOPT_POSTFIELDS, $query);// Set the request as a POST FIELD for curl.
- //Execute cUrl session
- $response = curl_exec($ch);
- curl_close($ch);
- ?>