Zoho and cURL in PHP, unable to communicate with server
Hello,
I am currently trying to use Zoho API to send some leads via "insertRecord" but my code won't work. I have tried all solutions I could find on internet, I have used 5 differents type of cUrl call (even the one in Zoho API) but nothing happened when I try to launch my request. Here is my XML
- $xml = "<?xml version='1.0' encoding='UTF-8'?>";
- $xml .='
- <Leads>
- <row no="1">
- <FL val="SMOWNERID">'.$ID.'</FL>
- <FL val="Company">Your Company</FL>
- <FL val="First Name">Hannah</FL>
- <FL val="Last Name">Smith</FL>
- <FL val="Email">testing@testing.com</FL>
- <FL val="Title">Manager</FL>
- <FL val="Phone">1234567890</FL>
- <FL val="Home Phone">0987654321</FL>
- <FL val="Other Phone">1212211212</FL>
- <FL val="Fax">02927272626</FL>
- <FL val="Mobile">292827622</FL>
- </row>
- </Leads>';
And here my cURL function that I found on this forum here
https://help.zoho.com/portal/en/community/topic/posting-with-php-curl- public static function sendXMLViaCurltoZoho ($url,$query=NULL,$xml=NULL) {
- $auth = 'MY AUTH';
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- //This CIPHER_LIST , this throw me an error "failed to setting cipher list" But without this line nothing // happen error or not juste nothing
- curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'rsa_rc4_128_sha');
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//Set to return data to string ($response)
- curl_setopt($ch, CURLOPT_POST, 1);//Regular post
- //Set post fields
- $query_string = "authtoken={$auth}&scope=crmapi";
- if (isset($query)) {
- $query_string .= $query;
- }
- if (isset($xml)) {
- $query_string .= "&xmlData={$xml}";
- }
- echo("SendXMLViaCurltoZoho - URL: \n----------\n".$url."-------------------?".$query_string."\n--------\n");
- print_r(curl_getinfo($ch));
-
- curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);// Set the request as a POST FIELD for curl.
-
- if( ! $result = curl_exec($ch))
- {
- trigger_error(curl_error($ch));
- }
-
- print_r(curl_getinfo($ch));
-
- curl_close($ch);
- return $response;
- }
Thanks for your help :D