gpt4 book ai didi

Slack 机器人无法将消息发送到带有 - 或 "channel-name"之类的空格的 channel

转载 作者:行者123 更新时间:2023-12-01 22:59:41 35 4
gpt4 key购买 nike

我的 slack 机器人无法将消息发送到带空格的 channel 或 - 如“ channel 名称”,但适用于单词 channel 。

  $curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://slack.com/api/chat.postMessage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{ \"channel\": \"channel-withspace\",\"text\": \"hello\"}",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"Authorization: Bearer <here>"
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

这里是错误:

{"ok":false,"error":"not_in_channel","warning":"missing_charset","response_metadata":{"warnings":["missing_charset"]}}

最佳答案


您可以将以下范围添加到您的机器人,以在不邀请机器人加入 channel 的情况下将消息发布到公共(public) channel 。

范围: chat:write.public

Send messages to channels @your_slack_app isn't a member of


https://api.slack.com/scopes/chat:write.public

关于Slack 机器人无法将消息发送到带有 - 或 "channel-name"之类的空格的 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72134779/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com