discord-php / DiscordPHP

An API to interact with the popular messaging app Discord
MIT License
985 stars 236 forks source link

401 Unauthorized with token #191

Closed nothotscott closed 7 years ago

nothotscott commented 7 years ago

I just started to use this, idk if it's an update or what, but I get this output:

[wayne]$ php DiscordBots/MMLsAdmin/Main.php
Fatal error: Uncaught exception 'Discord\Exceptions\DiscordRequestFailedException' with message 'Erorr code 401: There was an error processing the request. UNAUTHORIZED - {"code": 0, "message": "401: Unauthorized"} - users/@me' in /home/discordserver/vendor/team-reflex/discord-php/src/Discord/Helpers/Guzzle.php:212
Stack trace:
#0 /home/discordserver/vendor/team-reflex/discord-php/src/Discord/Helpers/Guzzle.php(134): Discord\Helpers\Guzzle::handleError(401, 'UNAUTHORIZED', Object(GuzzleHttp\Psr7\Stream), 'users/@me')
#1 /home/discordserver/vendor/team-reflex/discord-php/src/Discord/Helpers/Guzzle.php(66): Discord\Helpers\Guzzle::runRequest('get', 'users/@me', NULL, false, Array)
#2 /home/discordserver/vendor/team-reflex/discord-php/src/Discord/Discord.php(71): Discord\Helpers\Guzzle::__callStatic('get', Array)
#3 /home/discordserver/vendor/team-reflex/discord-php/src/Discord/Discord.php(71): Discord\Helpers\Guzzle::get('users/@me')
#4 /home/discordserver/DiscordBots/MMLsAdmin/Main.php(10): Discord\Discord->__construct(Arr in /home/discordserver/vendor/team-reflex/discord-php/src/Discord/Helpers/Guzzle.php on line 212

Here's my code:

<?PHP

include "DiscordBots/Environment.php";
include "$Root/vendor/autoload.php";

use Discord\Discord;

$Discord = new Discord(array(
    "token" => "my.coo-bot.token", // replaced with my actual app bot user token(which works on the lua discord wrapper)
));

$Discord->run();

?>
nothotscott commented 7 years ago

I found out it was my php CLI version was out of date.