我正在尝试使用斜杠命令制作一个简单的Slack App,该命令以随机语言发布“早安”。
到目前为止,我已经能够创建应用程序(斜杠命令),并将其发布为自己而不是应用程序名称。但是,如果任何伙伴尝试运行slash命令,它将以某种语言显示“早上好”,但对我的用户而言! :O
这是我当前拥有的代码。我已经简化了它,所以消息只是“ TestMessage”:
<?php
// Required to use proper message formating
// https://api.slack.com/docs/message-formatting
$message = "TestMessage";
$parameters = array(
'channel' => $_POST["channel_id"],
'text' => $message,
);
$parameters['token'] = "(the OAuth Access Token)xoxp-etc";
$paramBuild = http_build_query($parameters);
if ($query = $paramBuild)
$url = "https://slack.com/api/chat.postMessage?" . $query;
$headers = array();
$headers[] = "Content-Type: application/json;charset=iso-8859-1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
curl_close ($ch);
echo $result;
任何提示都非常感激:)