I’m working on an addon for my Garry’s Mod Server. I tried to get the username and avatar from the players, but it doesn’t return anything.
$id = $_GET["steamid"];
$url = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".$apikey."&steamids=".$id);
$table2 = json_decode($url, true);
$username = $table2["response"]["players"][0]["personaname"];
$profileimg = '<img src="'.$table['avatarfull'].'" alt="N/A"></img>';
So I tried to put my personal key and id into the url.
For privacy I replaced the apikey and steamid with XXX
$url = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=XXX&steamids=XXX");
Then I tried var_dump(json_decode($url, true));
and it returns NULL.
I also tried another code, but same result:
session_start();
$url = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=XXX&steamids=XXX");
var_dump(json_decode($url, true));
$content = json_decode($url, true);
$_SESSION['steam_personaname'] = $content['response']['players'][0]['personaname'];
$steamprofile['personaname'] = $_SESSION['steam_personaname'];
echo $steam_personaname;
echo $personaname;
echo $_SESSION['steam_personaname'];
Am I doing something wrong or did I miss something?
New contributor
UHDGamer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.