Skip to content

Instantly share code, notes, and snippets.

@looterz
Created May 31, 2014 20:15
Show Gist options
  • Save looterz/b7cccf168ac60837e6d2 to your computer and use it in GitHub Desktop.
Save looterz/b7cccf168ac60837e6d2 to your computer and use it in GitHub Desktop.
Garrysmod Steam API GetPlayerSummary example
local APIKey = "xxx";
function GetPlayerSummary( steamid64, callback )
local uri = string.format( "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=%s&steamids=%s", tostring( APIKey ), tostring( steamid64 ) );
local onSuccess = function( body, len, headers, code )
local json = (body and util.JSONToTable( tostring( body ) ) or {});
if( callback ) then
local tbl = (json.response.players and json.response.players[1] or {});
callback( tbl );
end
end
local onFailure = function( err )
if( callback ) then
callback( {} );
end
end
http.Fetch( uri, onSuccess, onFailure );
end
GetPlayerSummary( "76561197978593283", function( tbl )
PrintTable( tbl );
end );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment