Created
February 2, 2011 09:06
-
-
Save metamn/807444 to your computer and use it in GitHub Desktop.
Getting Twitter followers with JSONP, jQuery and Liquid
This file contains hidden or 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
<div id="items"> | |
{% assign twitter_id = "metamn" %} | |
{% assign twitter_limit = 50 %} | |
<script type="text/javascript"> | |
var counter = 0; | |
var BreakException= {}; | |
try { | |
jQuery.getJSON('http://twitter.com/statuses/followers.json?screen_name={{ twitter_id }}&callback=?',function(data){ | |
if (data) { | |
data.forEach(function(datum) { | |
if (datum.screen_name) { | |
var str = '<div id="item">'; | |
str += '<a href="http://twitter.com/' + datum.screen_name + '" title="' + datum.screen_name + '">'; | |
str += '<img class="avatar" src="' + datum.profile_image_url + '" alt="' + datum.screen_name + '" /></a>'; | |
str += '</div>'; | |
jQuery('#ecosystem #twitter #items').append(str); | |
counter++; | |
} | |
if(counter === {{ twitter_limit }}) throw BreakException; | |
}); | |
} | |
}); | |
} catch(e) { | |
if (e!==BreakException) throw e; | |
} | |
</script> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment