Steam api counting friends and games with PHP

Here are two handy functions to use in getting the games and friend count for a steam profile.

To count the games owned amount for a steam profile use:

function game_count($steamid)
{
    $data = json_decode(file_get_contents("https://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=YOURAPIKEY&steamid=" . $steamid . "&include_played_free_games=0&include_appinfo=1"));
    $games_count = $data->response->game_count;
    return $games_count;
}

echo game_count('754686934578698');

To count the friends a steam profile has use:

function friend_count($steamid)
{
    $data = json_decode(file_get_contents("https://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=YOURAPIKEY&steamid=" . $steamid . "&relationship=friend"));
    $friends_count = count($data->friendslist->friends);
    return $friends_count;
}

echo friend_count('754678978080');

Dont forget to replace YOURAPIKEY with your steam apikey