Getting Twitter Share Count using Spring Java Rest Service

oauth
service-status

#1

Hi,
As part of current caching system, we are trying to fetch twitter share count for our site url using “https://cdn.api.twitter.com/1/urls/count.json?url=” . We call this API from Spring Java Rest Controller and store the count into our system to show it for next few minutes. This Api works fine for few attempts for the same url. But many time this is throwing timeout exception even after retrial.

We tried to run curl command on above API for same url and we see the same behavior. Do we know, why it is happening. Does twitter blocks server Ip address if many requests comes from same server. Is it the right API to get count for a url or do we need to use different API.

Any help in this regard will be great.

Thanks
Amit


Retrieving URL Tweet counts on the backend
#2

That endpoint isn’t supported and will disappear soon: Retrieving URL Tweet counts on the backend


#3

Thanks. Do you know, what is the best to get share count from java services? Please suggest.


#4

Per the announcement about changes to the share buttons:

The Twitter REST API’s search endpoints are the best way to gather ad-hoc information about a URL shared on Twitter; full-archive search counts are available from Gnip.


Retrieving URL Tweet counts on the backend
#5

Thanks Andy, It looks like none of the API provides direct count results like “cdn.twitter.api.com”. I tried using oAuth search API https://api.twitter.com/1.1/search/tweets.json?q=www.example.com. But it returns whole search object , which has so many status_count. So not sure how to approach for this.

It will be great, if you can directly point me to the API url which provides count for a url, similar to “cdn.twitter.api.com


#6

There is no API endpoint that provides this information in a single call.


#7

Thanks Andy, So it means, To get the count we need to write custom logic based on search API. As I mentioned I tried search APIs too. But none of these API give response with all the tweet objects. So any other API which at least can provide all the tweets for a site url. I am sure, this must be pretty much common requirement. Thanks for help.


#8

As stated in the announcement about the change, you can either use the public search API, or the Gnip APIs. Those are the options available.


#9