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.
相关问题
- Rails how to handle error and exceptions in model
- CORS issue with Twitter api calls in Webpack dev s
- Twitter sign in crashes with TWTRInvalidInitializa
- Accessing Twitter through Javascript
- Swift 3: How to reverse a transparent Navigation B
相关文章
- is there a callback option with twitter's “fol
- Twitter name length in DB
- Twitter oauth refresh token
- Login with Twitter on iOS
- linqtotwitter - grab the saved credentials
- Getting the location using Tweepy
- Making any tweet favourite through iOS 5 twitter A
- LinqToTwitter - IsAuthorized always returns false
You can use the following API endpoint,
Note that the
http://urls.api.twitter.com/
endpoint is not public.)The endpoint will return a JSON string similar to,
On the client, if you are making a request to get the URL share count for your own domain (the one the script is running from), then an AJAX request will work (e.g.
jQuery.getJSON
). Otherwise, issue a JSONP request by appendingcallback=?
:Update:
As of 21st November 2015, this way of getting twitter share count, does not work anymore. Read more at: https://blog.twitter.com/2015/hard-decisions-for-a-sustainable-platform
I just read the contents into a json object via php, then parse it out..
Simple enough, and it serves my purposes perfectly.
I know that is an old question but for me the url
http://cdn.api.twitter.com/1/urls/count.json?url=http://stackoverflow.com
did not work inajax
calls due toCross-origin
issues.I solved using PHP
CURL
, I made a custom route and called it through ajax.It is important to use a
POST
because passsingurl
inGET
request cause issues.Hope it helped.
Yes, there is. As long as you do the following:
Issue a JSONP request to one of the urls:
Make sure that the request you are making is from the same domain as the
[URL_IN_REQUEST]
. Otherwise, it will not work.Example:
Making requests from
example.com
to request the count ofexample.com/page/1
. Should work.Making requests from
another-example.com
to request the count ofexample.com/page/1
. Will NOT work.The approved reply is the right one. There are other versions of the same endpoint, used internally by Twitter.
For example, the official share button with count uses this one:
JSONP support is there adding
&callback=func
.No.
http://dev.twitter.com/pages/tweet_button_faq#custom-shortener-count