How to get proper twitter share count for a url?



Hi All,

I am implementing a function to get twitter count for my url in php. When i am trying to get count using

  $json_string = file_get_contents("");
  $json = json_decode($json_string, true);
  echo intval( $json['count'] );

This return 5 count.
when i directly hit this url

in browser then i get proper count 6. So please help me how i can get absolute count in php


That URL is not a valid public endpoint for the API and will no longer respond after November 20th.

In addition, it also does not accurately reflect the share count - it doesn’t count Retweets, or variations of the URL, etc.

You’ll need to use the Search API to find Tweets that contain the URL, but that will only cover the past 7 days of Tweet content.


Can you please provide me any hint for search API and how i can get share count using seach API.


Docs for the Search API are available - you’ll want to use GET search/tweets and pass in your URL as a parameter on the query, then count the number of results returned (since you won’t get a single count number from the API).


I have tried to use search API for get twitter count. but in search API i can’t add URL Q parameter does not allow URL. Can you please help me to find out solution for get count. I am very upset. Please help


Hi andypiper,

Now i am trying to use this tool( for test search API like: with authentication But still i am not getting count fot url.

Please help its so urgent for me.


There’s a good chance that all the shares are older than 7 days, so the search API isn’t returning any results.


I am not getting count from search API please help me :tired_face:


I am trying to use search API like:
But did’t get count its always return data like:

  "statuses":  [],
  "search_metadata":  {
    "completed_in": 0.016,
    "max_id": 653500633182564400,
    "max_id_str": "653500633182564352",
    "query": "",
    "refresh_url": "?since_id=653500633182564352&",
    "count": 15,
    "since_id": 0,
    "since_id_str": "0"



If I put your query URL into the public Twitter search page I get no results.

Using it in the API, I also get no results.

Therefore there is a good chance that it has not been shared within the last 7 days (the scope of the Search API), otherwise you would have a result set of statuses containing the URL.

For example, here’s a search I tried containing a different URL, which worked.

twurl "/1.1/search/tweets.json?"

fun fact - searching just for does return a number of results. You’d have to check which link in the result set actually resolved to your target URL though, and then count those.


is their any replacement of count API. Please tell me this is very important



Today I found out that have same problem. And can’t track shares from this url{myURL}. Please can you tell me with what link this was replaced so I can use that proper one ?

How to get the twitter share count for a specific URL?
How to get count tweet share for url?

Per our announcement in September, this has been removed with no direct replacement at the current time. You can either use the search API, or filter on the streaming API for your URL and count the usage.

closed #14