Here is a quick tip to return a users twitter followers via a URL. The URL returns either XML or JSON by simply switching the targeted file. For example:
https://api.twitter.com/1/followers/ids.json?screen_name=candullo
This will output JSON, shown below for reference. If you would like XML in return, switch ‘ids.json’ to ‘ids.xml’. Also note the screen_name variable. You should know what that is.
Sample JSON return from Twitter:
{"next_cursor_str":"0","previous_cursor_str":"0","next_cursor":0,"ids":
[112419029,369480133,543227845,9081922,389620314,482381617,
406814796,473381272,208629427,15251303,466042209,145361708,99687348,
76556860,242279894,457257082],"previous_cursor":0}
Read the official Twitter documentation.
So what about the follower count? To get the follower count simply count the ‘ids’ node, a jQuery snippet is posted below.
var json = JSON.parse(YOUR_JSON_DATA);
var followers = json.ids.length;
That’s it.
