Skip to content

Instantly share code, notes, and snippets.

@jkishner
Created February 27, 2015 19:07
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 jkishner/a0b01f22253c477b7211 to your computer and use it in GitHub Desktop.
Save jkishner/a0b01f22253c477b7211 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<title>spotify for status board</title>
</head>
<body onload="spotifyAlbum()">
<script>
function spotifyAlbum() {
var xmlhttp = new XMLHttpRequest();
var url = "https://api.spotify.com/v1/albums/?ids="; // PUT ALBUM IDS, COMMA-DELIMITED, AFTER THE EQUALS SIGN AND BEFORE THE CLOSING QUOTE
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var myArray = JSON.parse(xmlhttp.responseText);
count = myArray.albums.length;
var output = "";
for (i=0;i<count;i++) {
output+= "<a href=launch://?url=" + myArray.albums[i].uri + "><img src=" + myArray.albums[i].images[1].url + " width=235 height=235></a><br>";
} // end loop
document.getElementById("results").innerHTML=output;
} // end readystate or status
} // end onreadystatechange
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
</script>
<p id="results"></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment