0

Twitter button share counter broken?

OpenShareCount can fix that...

Twitter about to close their 'count' api

About OpenShareCount

What is the problem?

Twitter’s share buttons used to have a share counter in them. , Twitter changed the look of their buttons and removed the share count along with the unofficial and undocumented API endpoint that powered it. Many third-party tweet buttons that used to display share counts stopped working.

In a blog post Twitter suggests that people who still want to know the number of shares for their articles should use the Twitter’s REST API to obtain the share counts by counting the results. For many users this is not feasible because of the technical complexity involved.

OpenShareCount aims to make this process a little simpler by providing a drop-in replacement for the old, undocumented and unofficial API endpoint that all the existing official and non-official share buttons were using. For people using Twitter's default button, OpenShareCount provides a bubble with a counter to place next to it.

The OpenShareCount project was built by Lead Stories LLC and is not affiliated, endorsed or in any other way connected with Twitter.

Shutdown of the “count.json” API endpoint

Tweet buttons displaying a share count used to get this information by calling a link hosted by Twitter that looked like this:
https://cdn.api.twitter.com/1/urls/count.json?url=http://www.example.com
This call would return some JSON-formatted data that looked like this: {"count":44934,"url":"http:\/\/www.example.com\/"}

This doesn't work anymore since November 20th, 2015!

“Official” alternative

Twitter suggests to use their REST API instead. If you do a search for a URL using Twitter’s REST API, you could theoretically count the results and use that number.

These search results only go back a few days so over time the count would become inaccurate. Additionally tweets from private accounts do not show up.

Using the REST API requires a fair bit of programming and involves authentication. Not very easy for the average user. Still, better than nothing.

OpenShareCount will help you:

OpenShareCount can periodically do the search for you and it will keep track of the number of old search results so the count stays up-to-date over time.

The Twitter API limits the number of searches that can be done in a set time period on behalf of individual users.

OpenShareCount needs permission to use your Twitter account so it can do these searches on your behalf for the links on your website.

Once you are signed up we will provide you the share count data in exactly the same format as the old Twitter endpoint.

This should allow you to make the count on any third-party Twitter button work again.

Twitter's own buttons no longer show a count so we also provide a bubble with a counter that can be placed next to it.

How to use OpenShareCount:

To use OpenShareCount, first sign up or it will not work:

  • Sign up with your Twitter account and give us permission to use it to do the necessary searches.
  • You can only sign up for one domain (for example www.mydomain.com) per Twitter account.
  • If you sign up multiple times with the same Twitter account, OpenShareCount will only be enabled for the last domain you used.
  • Pick the solution for the type of Twitter button on your site

OpenShareCount with a standard Twitter button:

Copy the code and paste it into the source of your website, right after the code for the existing Twitter button and don't forget to sign up first or it won't work.

Large bubble (goes with large button):

0

Small bubble (goes with standard size button):

0

Advanced usage: Put in data-url="http://link_goes_here" if you want to show the count for a particular link instead of for the current page. Change the value for data-dir to 'right', 'top' or 'bottom' to make the bubble point in a different direction, and/or add data-width="..." or data-height="..." to change the width or height of the bubble.

Large bubble pointing downwards, showing the count for http://leadstories.com:

0

OpenShareCount with a custom Twitter button:

To use the OpenShareCount API, replace calls to Twitter’s old link with calls to OpenShareCount’s:

  • Check the source code of the twitter button you are using, and look for “http://cdn.api.twitter.com/1/urls/count.json?url=”
  • Replace this with “http://opensharecount.com/count.json?url=” and if you see anything looking like "&callback=?" at the end remove that part.
  • If you see any references to 'jsonp' in the code related to the Twitter count, change that to 'json'.
  • Don't forget to sign up first or it won't work!
  • That’s it!

Note: we support calls over https too, simply call “https://opensharecount.com/count.json?url=” (or “//opensharecount.com/count.json?url=” if your pages are available both via http:// and https://)

IMPORTANT: if you leave the 'jsonp' or the '&callback=?' parts in, we reserve the right to block requests for your domain until you make changes. Such requests can't be cached and they slow things down for us and for your users.

Important notes: it can take some time for search results to come in, so initially the count that is reported will be zero on all links. Contact us if after one hour it is still zero. Due to limitations on the Search API initially only tweets from the past week or so will be counted. Tweets going forward will be counted and added to the total. Tweets from private accounts will not be counted. Results will only be returned for links in the domain you signed up with. If you need results from multiple domains, sign up with multiple Twitter accounts.

Sign up

By signing up you give OpenShareCount permission to use your Twitter account to perform searches using Twitter’s API on your behalf. We will not pass on your email address to third parties.

If you use a third-party tweet button, make sure it is not making JSONP calls (ending in "&callback=...") to fetch data.