有什么方法可以保留包含特定主题标签或单词的推文计数?例如,要统计所有包含主题标签,#apple的推文还是所有包含“ iphone”的推文?

最佳答案

此php源代码以获取计数hashtag(#)

<?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]);
      }
   }

   getTweets($hashtag,1);
   echo $total;
?>


谢谢..

关于twitter - 用标签计算推文,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5144135/

10-11 22:05