Skip to content

Instantly share code, notes, and snippets.

@plamere
Created January 11, 2012 13:08
Show Gist options
  • Save plamere/1594579 to your computer and use it in GitHub Desktop.
Save plamere/1594579 to your computer and use it in GitHub Desktop.
Top hotttest Twitter artists
<!DOCTYPE html>
<html>
<head>
<title>Top Twitter</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<link type="text/css" href="styles.css" rel="stylesheet" />
</head>
<body>
<h1 id='title'> Top 100 artists with verified Twitter accounts</h1>
<ol id="results"> </ol>
<div id="footer"> Powered by <a href="http:/developer.echonest.com">The Echo nest </a></div>
</body>
<script type="text/javascript">
function fetchTopTwitterArtists() {
var url = 'http://developer.echonest.com/api/v4/artist/top_hottt?callback=?';
$.getJSON(url, { 'api_key': 'N6E4NIOVYMTHNDM8J', 'format':'jsonp',
'results': 100, 'bucket': ['hotttnesss', 'id:twitter'], 'limit': true}, function(data) {
for (var i = 0; i < data.response.artists.length; i++) {
var artist = data.response.artists[i];
var elem = $("<li>");
var link = $("<a>");
var handle = artist.foreign_ids[0].foreign_id.replace('twitter:artist:', '');
link.attr('href', 'http://twitter.com/' + handle);
link.text(artist.name);
elem.append(link);
$("#results").append(elem);
}
});
}
$(document).ready(function() {
jQuery.ajaxSettings.traditional = true;
fetchTopTwitterArtists();
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment