我想使用 chatwoot api 发送消息。 https://www.chatwoot.com/developers/api/#tag/Messages/operation/create-a-new-message-in-a-conversation
我尝试了这段代码:
<?php
$ch = curl_init("https://mydomain.de/api/v1/accounts/1/conversations/100/messages");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(
array(
"content" => "string",
"message_type" => "outgoing",
"private" => true,
"content_type" => "cards"
)
));
curl_setopt($ch, CURLOPT_HTTPHEADER,
array (
'api_access_token: XXX'
),
);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
echo '<pre>';
print_r($response);
echo '</pre>';
?>
回应:
Array
(
[errors] => Array
(
[0] => You must log in or register before you can proceed.
)
)
有什么想法吗?
``` [0] => You must log in or register before you can proceed.```
是的,错误是因为您没有注册或没有用户与您关联,您无法访问以获取对话id:100的消息列表!