且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Zoho API V2更新记录

更新时间:2023-02-06 08:10:51

上面的代码像这样构造输入JSON [{"data":{"City":"Egham"}}].根据ZOHO CRM APIs( API帮助).

The above code constructs input JSON like this [{"data":{"City":"Egham"}}]. This JSON is not valid as per the ZOHO CRM APIs(API help).

应该是这样的{"data":[{"City":"Egham"}]}.

像这样更改代码:

$apiUrl = "https://www.zohoapis.com/crm/v2/Leads/" . {valid record id here};

$fields = json_encode(array("data" => array(["City" => "Egham"])));

// *strlen must be called after defining the variable. So moved headers down to $fields*

$headers = array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($fields),
    sprintf('Authorization: Zoho-oauthtoken %s', {valid auth token here})
);


$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);

$result = curl_exec($ch);

curl_close($ch);