Is there a way to get the twitter share count for

2019-01-29 23:44发布

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 articles if you're looking for an example. I'm attempting to do this through javascript. Any help is appreciated.

标签: twitter
12条回答
欢心
2楼-- · 2019-01-30 00:43

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!

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-01-30 00:46
别忘想泡老子
4楼-- · 2019-01-30 00:47

This comment https://stackoverflow.com/a/8641185/1118419 proposes to use Topsy API. I am not sure that API is correct:

Twitter response for www.e-conomic.dk:

http://urls.api.twitter.com/1/urls/count.json?url=http://www.e-conomic.dk

shows 10 count

Topsy response fro www.e-conomic.dk:

http://otter.topsy.com/stats.json?url=http://www.e-conomic.dk

18 count

查看更多
Ridiculous、
5楼-- · 2019-01-30 00:47

This Javascript class will let you fetch share information from Facebook, Twitter and LinkedIn.

Example of usage

<p>Facebook count: <span id="facebook_count"></span>.</p>
<p>Twitter count: <span id="twitter_count"></span>.</p>
<p>LinkedIn count: <span id="linkedin_count"></span>.</p>
<script type="text/javascript">
    var smStats=new SocialMediaStats('https://google.com/'); // Replace with your desired URL
    smStats.facebookCount('facebook_count'); // 'facebook_count' refers to the ID of the HTML tag where the result will be placed.
    smStats.twitterCount('twitter_count');
    smStats.linkedinCount('linkedin_count');    
</script>

Download

https://404it.no/js/blog/SocialMediaStats.js

More examples and documentation

Javascript Class For Getting URL Shares On Facebook, Twitter And LinkedIn

查看更多
虎瘦雄心在
6楼-- · 2019-01-30 00:49

This is not possible anymore as from today, you can read more here:

https://twitter.com/twitterdev/status/667836799897591808

And no plans to implement it back, unfortunately.

Up vote so users do not lose time trying out.

Update: It is however possible via http://opensharecount.com, they provide a drop-in replacement for the old private JSON URL based on searches made via the API (so you don't need to do all that work).

It's based on the REST API Search endpoints. Its still new system, so we should see how it goes. In the future we can expect more of similar systems, because there is huge demand.

查看更多
戒情不戒烟
7楼-- · 2019-01-30 00:50

Yes,

https://share.yandex.ru/gpp.xml?url=http://www.web-technology-experts-notes.in

Replace "http://www.web-technology-experts-notes.in" with "your full web page URL".

Check the Sharing count of Facebook, Twitter, LinkedIn and Pinterest

http://www.web-technology-experts-notes.in/2015/04/share-count-and-share-url-of-facebook-twitter-linkedin-and-pininterest.html

Update: As of 21st November 2015, Twitter has removed the "Tweet count endpoint" API.

Read More: https://twitter.com/twitterdev/status/667836799897591808

查看更多
登录 后发表回答