Created
July 30, 2014 14:22
-
-
Save mattandrews/42e29c296b92184d779c to your computer and use it in GitHub Desktop.
This file contains 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
<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