php获取40001,php - Discord API错误#40001未经授权 - SO中文参考 - www.soinside.com
我通過OAuth2 URL(https://discordapp.com/api/oauth2/authorize?client_id=398437519408103444&permissions=59392&scope=bot)驗證我的機器人
我想在我的discord服務器上發送消息到頻道
碼:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://discordapp.com/api/channels/'.$channel_id.'/messages');
curl_setopt($curl, CURLOPT_HTTPHEADER, [
// 'Content-Type: application/json',
'Authorization: Bot '.$this->token
]);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode([
'content' => 'test'
]));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($curl);
curl_close ($curl);
var_dump(json_decode($server_output, true));
但回應是:
array(2) {
["code"]=>
int(40001)
["message"]=>
string(12) "Unauthorized"
}
總結
以上是生活随笔為你收集整理的php获取40001,php - Discord API错误#40001未经授权 - SO中文参考 - www.soinside.com的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用 ref 对已渲染到页面的节点进行标
- 下一篇: 日志库EasyLogging++学习系列