Is there a way to get the twitter share count for a specific URL?

前端 未结 12 843
故里飘歌
故里飘歌 2020-12-22 20:04

I looked through the API documentation but couldn\'t find it. It would be nice to grab that number to see how popular a url is. Engadget uses the twitter share button on a

12条回答
  •  伪装坚强ぢ
    2020-12-22 20:58

    This way you can get it with jquery. The div id="twitterCount" will be populated automatic when the page is loaded.

    
         function getTwitterCount(url){
             var tweets;
             $.getJSON('http://urls.api.twitter.com/1/urls/count.json?url=' + url + '&callback=?',             function(data){
             tweets = data.count;
             $('#twitterCount').html(tweets);
         });
         }
         var urlBase='http://http://stackoverflow.com';
         getTwitterCount(urlBase); 
    
    

    Cheers!

提交回复
热议问题