Skip to content

Instantly share code, notes, and snippets.

@mattandrews
Created July 30, 2014 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattandrews/42e29c296b92184d779c to your computer and use it in GitHub Desktop.
Save mattandrews/42e29c296b92184d779c to your computer and use it in GitHub Desktop.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
var urlMajor = "http://anyorigin.com/dev/get?url=http%3A//api.steampowered.com";
var apiKey = "9E19315419261EF7FFDE640368790BAB";
function apiRequest(steamID) {
var that = this;
var deferred = $.Deferred();
this.players = {};
function ajax() {
$.ajax({
url: urlMajor + "/ISteamUser/GetPlayerSummaries/v0002/%3Fkey%3D" + apiKey + "%26steamids%3D" + steamID + "&callback=?",
type: 'get',
dataType: 'jsonp',
success: function(data) {
that.players = data.contents.response.players;
deferred.resolve(that);
}
});
}
this.getPlayers = function() {
return this.players;
};
// initalise the object
ajax();
return deferred.promise();
}
var api = new apiRequest('76561198063155257');
$.when(api).done(function(game) {
var name = game.getPlayers();
console.log(name);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment