Followers count without authentication


#1

How can I get followers count and total tweets count without authentication?


#2

I was trying to use this:
GET http://api.twitter.com/1/account/totals.json but it doesn’t display anything

Than I’ve tried this one:
$.getJSON(“http://api.twitter.com/1/users/show.json?screen_name=[name]”,
function(data) { … });

and even though it displays information when url is paste to browser, but don’t work in this code.
(it also has limit of 150 request per hour)


#3

The /account/totals.json endpoint requires authorization, so you’ll need to pass credentials to access that URL.

It looks like the problem you’re having with the second request is that you’re trying to make a cross-domain request from Javascript. You’ll need to use JSONP for this kind of request. It looks like jQuery supports JSONP by adding the string callback=? to the URL, so the following request should work:

$.getJSON("https://api.twitter.com/1/users/show.json?callback=?&screen_name=kurrik", function(data) { console.log(data); });

#4

This is true, you need the callback=? in the url string when using $.getJSON method… but why?

Here’s what jQuery API says:

JSONP
If the URL includes the string “callback=?” (or similar, as defined by the server-side API), the request is treated as JSONP instead. See the discussion of the jsonp data type in $.ajax() for more details.

from source: http://api.jquery.com/jQuery.getJSON/

I know this is jQuery related, but I think Twitter should openly post this in their API documentation. Something along the lines of “Remember, if your are making the request cross domain make sure to request in JSONP instead of JSON” at the very least. Bonus if they add “for example when using jQuery add callback=? to the URL”.


#5

-_-


#6

hwewwww


#7