我想通过 PHP CURL 更新对讲机的 custom_attributes。
我将 user_id 和 email 作为参数传递,但仍然出现此错误。{"code":"400","message":"必须提供用户电子邮件、user_id 或anonymous_id"}
try {
$postData = json_encode(array(
"user_id" => strval($userDetails["id"]),
"email" => $userEmail,
"custom_attributes" => ['unsubscribed_from_emails' => 'true']
));
$postHeader = [
'Authorization: Bearer <Access Token>',
'Accept: application/json',
'Content-Type: application/json -d'
];
$curl = curl_init("https://api.intercom.io/users");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HTTPHEADER, $postHeader);
curl_exec($curl);
curl_close($curl);
} catch (Exception $e) {
error_log($e->getMessage());
}