hashtag count

daldrovandi
@daldrovandi Davide Aldrovandi

Hi all,
how can I retrieve the number of tweetws for a specific hashtag?
Is it possible?
Many thanks,
davide

2 years 38 weeks ago

Replies

episod
@episod Taylor Singletary

There's no direct API method to retrieve this kind of count. Depending on the popularity and frequency of the hashtag, you might be able to use the Streaming API to track the occurrence of the hashtag in real time. You'll have a much easier time tracking this number from "present to the future" rather than trying to excavate the number from the past.

2 years 38 weeks ago
rajatkumar_
@rajatkumar_ ŘÀĴÁŤ ĶÜMÀŔ

hello if there is no option to count #Tag's then how www.iplt20.com is counting # tags can you plz tell me ! Sir

51 weeks 5 days ago
tittuonnet
@tittuonnet Tittu Varghese

I too counting it http://kites.ieee-link.org/mytweets_leader_board.php check out it.. It's very easy using php.. :) just some tricks only..! even i'm counting it tweet by a specific person with a specific hash tag..!

Total tweet count is also possible.. It's also included in that site..

45 weeks 3 days ago
leelayz
@leelayz Suva Ghosh

Hey @episod,

Someone had posted this code block on Stackoverflow -
<?php
global $total, $hashtag;
//$hashtag = '#supportvisitbogor2011';
$hashtag = '#australialovesjustin';
$total = 0;
function getTweets($hash_tag, $page) {
global $total, $hashtag;
$url = 'http://search.twitter.com/search.json?q='.urlencode($hash_tag).'&';
$url .= 'page='.$page;
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
$json = curl_exec ($ch);
curl_close ($ch);
//echo "

<

pre>";
//$json_decode = json_decode($json);
//print_r($json_decode->results);

$json_decode = json_decode($json);
$total += count($json_decode->results);
if($json_decode->next_page){
$temp = explode("&",$json_decode->next_page);
$p = explode("=",$temp[0]);
getTweets($hashtag,$p[1]);
}

}

Does this work ?
Where do I include to get the libraries for the functions, mentioned ?

Cheers
Suva

2 years 26 weeks ago
0nCeR
@0nCeR MacDon

well i'am having the same problem..:(, but the code above worth trying...

2 years 10 weeks ago
henrahmagix
@henrahmagix Henry Blyth

@daldrovandi @leelayz Inspired by that PHP, I wrote the following: https://github.com/henrahmagix/tweetCount

Seems silly to do it in PHP when Javascript can natively handle JSON, and doesn't need an AMP stack to run. Saying that, it took me 20mins to realise it!

2 years 10 weeks ago
tittuonnet
@tittuonnet Tittu Varghese

Yeah it's possible. I had developed it for a tweet contest (MyTweets). It counts the number of tweets for a specific hashtag and also it will find out count of number of tweets by each persons uniquely and store it into database. Now it's live at http://goo.gl/7DtrP . It's developed using php.

45 weeks 3 days ago
hbksagar
@hbksagar Krupa Sagar

@tittuonnet I looked into your website and that is exactly i am looking for. But in twitter api version 1.1 we are not able to search all the entries based on a hashtag and is limited to 100. Please suggest a solution.

Thank you in advance.
Regards,
hbksagar

44 weeks 3 days ago
tittuonnet
@tittuonnet Tittu Varghese

Currently twitter stopped the API :( i'm sorry guys.. If any one needed i will share the source.. no probs..

35 weeks 2 hours ago
parthasarma
@parthasarma partha protim sarma

Hi Tittu,

Can you share the code and database design. You can contact me at partha.sarma@outlook.com

20 weeks 3 hours ago
Arbtrend
@Arbtrend ترند العرب

Is it possible to show us the source code please?

I am developing a similar script but it shows the highest used hashtag for the past X hours.

39 weeks 3 days ago
Aadil_adi
@Aadil_adi aadil afzal

so kindly you share us the code, where we show total no of post to a specific user.

37 weeks 6 days ago
JulsTerobias
@JulsTerobias Juls

Hi,

Did he share his code?

36 weeks 5 days ago
deshpandeamrut
@deshpandeamrut Amrut Deshpande

How could you do this? pls contact me amrutdeshpande@hotmail.com

35 weeks 4 hours ago
alpipita
@alpipita MERMAID

Hi, anybody can help me. How can I count and get total tweets using Twitter 1.1? Thanks.

43 weeks 2 days ago
ackuario2020
@ackuario2020 Sebastian Lopez

Hi guys, I can share my approach. The first thing you have to know you can't count tweets older than a week and max 100 per request.
So we save the partial count and the last id we receive (since_id). Then we can update the count using a cronjob (more accurate).

This is what you need:
- cUrl
- Twitter API PHP (https://github.com/J7mbo/twitter-api-php) or a similar one
- Create a twitter app and get auth data (https://dev.twitter.com/apps)

  1. // We get the saved stats from file, database or wherever
  2. $total = "";
  3. $since_id = "";
  4. $hashtag = "#test";
  5.  
  6. // twitter api options
  7. $settings = array(
  8.             'oauth_access_token' => "",
  9.             'oauth_access_token_secret' => "",
  10.             'consumer_key' => "",
  11.             'consumer_secret' => ""
  12. );
  13.  
  14. $twitter = new TwitterAPIExchange($settings);
  15.  
  16. if(($since_id)) {
  17.     $query = '?q='. $hashtag .'&count=100&since_id='.$since_id; 
  18. } else {
  19.     $query = '?q='. $hashtag .'&count=100'; 
  20. }
  21. // Request
  22.  $response = $twitter->setGetfield($query)
  23.                             ->buildOauth('https://api.twitter.com/1.1/search/tweets.json', 'GET')
  24.                             ->performRequest();
  25.  $tweets = json_decode($response);
  26.  
  27. // Last
  28. $position = (array) $tweets->statuses;
  29. $last = reset($position);
  30.  
  31. // Count
  32. $total_temp = count($tweets->statuses);
  33.  
  34. if(isset($last->id)) { // to avoid counting the last one 
  35.   $total_temp -= 1;
  36. }
  37.  
  38. $total += $total_temp;
  39.  
  40. // save data to file, database, etc (since_id = $last->id, total = $total)  

It's not perfect because if the hashtag exists using this code you cant count more than 100 tweets (you should to iterate from present to past and get the previous one but instead of since_id you have to use max_id please check https://dev.twitter.com/docs/working-with-timelines). And the other important thing is you should run a cronjob each 30 seconds / 1 minute because you have request limit (450 each 15 minutes).

That's all....if you need help just ask.

Bye guys.

36 weeks 1 day ago
episod
@episod Taylor Singletary

Worth keeping in mind that the Search API doesn't index all tweets, so counting them using the Search API isn't necessarily the best way to track the occurrences of tweets matching a term. It is much better to use the Streaming API to collect and count tweets in real time instead.

36 weeks 1 day ago
tittuonnet
@tittuonnet Tittu Varghese

Search API doesn't.. BUT a programmer can count using some basic tricks/logic's :p

35 weeks 2 hours ago
episod
@episod Taylor Singletary

Just as long as you recognize that what you're counting are the subset of tweets you found in Search, not all public tweets that would match.

34 weeks 6 days ago
ackuario2020
@ackuario2020 Sebastian Lopez

I think if you're interested in helping us you could give us that tips!

34 weeks 6 days ago
Jitenderssingh7
@Jitenderssingh7 Jitender singh

please provide me the source code for the counting hash tweets....please it an urgency

28 weeks 1 day ago
AntiFraudTeam
@AntiFraudTeam AntiFraudTeam

I need a simple application just count and write to mysql db for one hastag....

9 weeks 2 days ago