Upon coming face to face with the mighty cross-origin request block, and needing to get a JSON file from an external source, I decided to use the Yahoo Query Language in order to achieve this.
I'm starting to wonder however whether this code is really the most efficient way of doing it, considering the source can be in JSON, XML and Steams own language.
function getID64(name) {
var Site = 'https://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/?key=' + key + '&vanityurl=' + name;
//console.debug("getID64 - " + Site);
var yql = 'https://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from json where url="' + Site + '"') + '&format=json&callback=?';
//console.debug("getID64 - " + yql);
$.getJSON(yql, function(data) {
app.id64 = data.query.results.response.steamid;
//console.debug("getID64 - " + app.id64);
//From here onwards it's just changing some elements on the webpage and starting the next function
document.getElementById("Steam64ID2").innerHTML += " " + app.id64;
document.getElementById("Steam64ID").value += "" + app.id64;
document.getElementById("SteamID2").innerHTML += " " + document.getElementById("SteamID").value;
getFriendList(document.getElementById('Steam64ID').value);
});
}
Considering for the first half I am only trying to get and parse the file, is there an easier way of doing this?