我已经创建了使用第一版的Zoho API,现在他们迁移到第二版,我的使用curl函数的第一版php代码工作得很好,如下所述。
<?php
$auth="a5014536e7303c218e983f9b2da7ae00";
$xml= "
<Leads>
<row no="1">
<FL val="City">Chennai</FL>
</row>
</Leads>
";
$result = insert($auth,$xml);
print_r($result);
function insert($auth,$xml)
{
$curl_url ="https://crm.zoho.in/crm/private/xml/Leads/insertRecords";
$curl_post_fields= "authtoken=".'$auth'.&scope=crmapi&xmlData=".$xml."";
$ch = curl_int();
curl_setopt( $ch, CURLOPT_URL, $curl_url);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION,true);
curl_setopt( $ch, CURLOPT_TIMEOUT,60);
curl_setopt( $ch, CURLOPT_POST,1);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER,true);
curl_setopt( $ch, CURLOPT_POSTFIELDS,$curl_post_fields);
$response= curl_exec($ch);
curl_close($ch);
return $response;
}
?> 但是当我使用ZOHO Documention API Documentation 1 API Documentation 2迁移到第二个版本时,它不能运行,我不知道为什么有时它会出现白屏错误500次,下面是版本2代码。
<?php
$apiUrl = "https://www.zohoapis.com/crm/v2/Leads/";
$fields = json_encode(array("data" => array(["City" => "Egham"])));
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($fields),
'Authorization: Zoho-oauthtoken 4869c41171910edf553c07461c59a059',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$response = curl_exec($ch);
curl_close($ch);
return $response;
?>有没有人能告诉我哪里做错了,或者能帮我修改代码?
发布于 2020-01-22 19:33:45
将API URL替换为
$apiUrl = "https://www.zohoapis.com/crm/v2/Leads/";至
$apiUrl = "https://www.zohoapis.com/crm/v2/Leads";https://stackoverflow.com/questions/59858610
复制相似问题