I am trying to insert a lead into ZOHO CRM using php curl.Unable to create a lead dynamically.I am using auth token to send request to ho api with xml data.Not able to get the error to fix and insert lead.Please suggest the fix.Below is entire code i am running
我收到错误4600.无法处理您的请求。请确认您是否输入了正确的方法名称,参数和参数值。
XMLdata是一个带有动态数据的xml,其中包含要作为潜在客户插入的数据。
$url = "https://crm.zoho.com/crm/private/xml/Leads/insertRecords?authtoken=195509dec8d5fae8082083bbe2fc04c5&scope=crmapi&newFormat=1&version=2&duplicateCheck=2";
$post=array("newFormat"=>'1',"xmlData"=>$xmlData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$post);
$result = curl_exec($ch);
curl_close($ch);
答案 0 :(得分:2)
错误代码4600
表示您尝试发送包含无效参数的潜在客户,可以是值或字段名称,
API参数或API参数值不正确。还要检查方法 API网址中的名称和/或拼写错误。
主要是值......所以只需验证您在变量$xmlData
内发送的值,验证该XML是否是有效的XML,如果您希望可以使用此包装器,与zoho进行交互,我会使用它...
Zoho CRM library for PHP 5.3+
希望有所帮助:)
答案 1 :(得分:1)
<?php
$xml =
'<?xml version="1.0" encoding="UTF-8"?>
<Leads>
<row no="1">
<FL val="First Name">Digant</FL>
<FL val="Last Name">Shah1</FL>
<FL val="Email">digant.shah91@gmail.com</FL>
<FL val="Department">php</FL>
<FL val="Phone">999999999</FL>
<FL val="Fax">99999999</FL>
<FL val="Mobile">99989989</FL>
<FL val="Assistant">none</FL>
</row>
</Leads>';
$auth="*******************";
$url ="https://crm.zoho.com/crm/private/xml/Leads/insertRecords";
$query="authtoken=".$auth."&scope=crmapi&newFormat=1&xmlData=".$xml;
$ch = curl_init();
/* set url to send post request */
curl_setopt($ch, CURLOPT_URL, $url);
/* allow redirects */
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
/* return a response into a variable */
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
/* times out after 30s */
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
/* set POST method */
curl_setopt($ch, CURLOPT_POST, 1);
/* add POST fields parameters */
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);
echo $response;
?>