jquery - New Twitter API - they say no way to use ajax but will this work? -


i working on fixing older connection string twitter's api pulls number of followers display it.

the site : www.democracywatch.ca can see current request syntax when "inspect element" on empty twitter square on bottom right (it should have number of followers , should display of recent feeds).

the current code jquery/ajax:

                    jquery(function($) {                     $.ajax({                         url: 'https://api.twitter.com/1.1/users/show.json',                         data: {screen_name: 'democracywatchr'},                         datatype: 'jsonp',                         success: function(data) {                             $('#followers div.twitter').html(data.followers_count);                         }                     }); 

you can see tried replace http https , added .1 before /users in url getting "unauthorized" response them. understand on should oauth requests... not sure code add have in order authorize request. web app exists , have necessary tokens not sure method of implementing them current jquery function.

i found this: http://sobolev.us/how-to-use-twitter-oauth-v1-1-with-javascriptjquery/ implementing code easy how make call follower number response?

is there way can think of implementing tokens right current code?

to continue previous answer working example:

$dom = new domdocument(); $dom->stricterrorchecking = false; $dom->loadhtmlfile("https://twitter.com/democracywatchr"); $xpath = new domxpath($dom); $followers = $xpath->query("//a[@data-element-term='follower_stats']/strong")->item(0)->nodevalue; echo $followers; 

will give number of followers. warned: work long twitter doesn't change it's interface although little rewriting should trick in situation.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -