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"

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值