我通过OAuth2 URL(/api/oauth2/authorize?client_id=398437519408103444&permissions=59392&scope=bot)验证我的机器人
我想在我的discord服务器上发送消息到频道
码:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, '/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"
}