对讲机 API CURL 获取错误 "code":"400","message":"User email, user_id or anonymous_id must be supplied"
Intercom API CURL Getting error "code":"400","message":"User email, user_id or anonymous_id must be supplied"
我想通过 PHP CURL 更新对讲机 custom_attributes。
我正在传递 user_id 和电子邮件作为参数仍然收到此错误。
{"code":"400","message":"User email, user_id or anonymous_id must be supplied"}
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());
}
根据 php.net 关于 CURLOPT_POSTFIELDS:
This parameter can either be passed as a urlencoded string like
'para1=val1¶2=val2&...' or as an array with the field name as key
and field data as value. If value is an array, the Content-Type header
will be set to multipart/form-data.
http://us2.php.net/manual/en/function.curl-setopt.php
但是你传递了 json。
我想通过 PHP CURL 更新对讲机 custom_attributes。
我正在传递 user_id 和电子邮件作为参数仍然收到此错误。 {"code":"400","message":"User email, user_id or anonymous_id must be supplied"}
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());
}
根据 php.net 关于 CURLOPT_POSTFIELDS:
This parameter can either be passed as a urlencoded string like 'para1=val1¶2=val2&...' or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data.
http://us2.php.net/manual/en/function.curl-setopt.php
但是你传递了 json。