Created
May 31, 2014 20:15
-
-
Save looterz/b7cccf168ac60837e6d2 to your computer and use it in GitHub Desktop.
Garrysmod Steam API GetPlayerSummary example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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