I explain my problem: I want the user to see these discord servers, so I retrieve the information with "https://discordapp.com/api/users/@me/guilds" but by decoding the file and using that $guild->id
and $guild->icon
I have it's errors
Notice: Trying to get property 'id' of non-object in C:\xampp\htdocs\connected.php on line 102
Notice: Trying to get property 'icon' of non-object in C:\xampp\htdocs\connected.php on line 102
So if you can help me, it's very cool
<?php
//...Other code...
$url="https://discordapp.com/api/users/@me/guilds";
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer {$access_token}")
));
$test = (curl_exec($ch));
echo $test; // for know if it's work i echo the json file
$guild = json_decode(curl_exec($ch), true);
curl_close($ch);
echo "<img height='145' width='145' src='https://cdn.discordapp.com/icons/{$guild->id}/{$guild->icon}.png' />"; //img guilds
?>