Closed poyrazhancilar closed 6 years ago
@GameUx-Studios As mentioned in https://github.com/wohali/oauth2-discord-new/issues/3#issuecomment-367037473, this library only gives you the OAuth token.
Once you've used my library to get set up the scope and have gotten a bot token from Discord, make for example a new RestCord client using the token. You can then use it to retrieve the data you're looking for.
you don't need RestCord to get the user-avatar tho.. it's already available through your library by accessing the user variable for the avatar.
$user = $provider->getResourceOwner($token);
$avatar = "https://cdn.discordapp.com/avatars/" . $user->getId() . "/" . $user->getAvatar() . ".png";
should work therefor..
Oh right, I'd forgotten! Thanks for the reminder. :smile:
you don't need RestCord to get the user-avatar tho.. it's already available through your library by accessing the user variable for the avatar.
$user = $provider->getResourceOwner($token);
$avatar = "https://cdn.discordapp.com/avatars/" . $user->getId() . "/" . $user->getAvatar() . ".png";
should work therefor..
I tried. But I get this errors:
[23-Oct-2018 19:43:03 Europe/Istanbul] PHP Fatal error: Uncaught Error: Call to undefined method Wohali\OAuth2\Client\Provider\DiscordResourceOwner::getAvatar() in /home/gameuxst/discordbotlist.gameuxst.com/login.php:58 Stack trace:
thrown in /home/gameuxst/discordbotlist.gameuxst.com/login.php on line 58
@GameUx-Studios it's $user->getAvatarHash() sorry ^^
@GameUx-Studios it's $user->getAvatarHash() sorry ^^
Thank you :)
you don't need RestCord to get the user-avatar tho.. it's already available through your library by accessing the user variable for the avatar. $user = $provider->getResourceOwner($token); $avatar = "https://cdn.discordapp.com/avatars/" . $user->getId() . "/" . $user->getAvatar() . ".png"; should work therefor..
I tried. But I get this errors:
[23-Oct-2018 19:43:03 Europe/Istanbul] PHP Fatal error: Uncaught Error: Call to undefined method Wohali\OAuth2\Client\Provider\DiscordResourceOwner::getAvatar() in /home/gameuxst/discordbotlist.gameuxst.com/login.php:58 Stack trace: #0 {main} thrown in /home/gameuxst/discordbotlist.gameuxst.com/login.php on line 58
the url to get user avatar is https://cdn.discordapp.com/avatars/8917045513364434/102f0fe2cf4086daddab8bdd6af98d.png https://cdn.discordapp.com/avatars/{user.id}/{user.avatar}.png
Is any code to get user avatar like:
$user->getAvatar();
Thanks.