2011-02-28 7 views
2

특정 해시 태그 또는 단어가 포함 된 짹짹 개수를 유지하는 방법이 있습니까? 예를 들어, 해시 태그, #apple 또는 'iphone'이 포함 된 모든 트윗을 포함하는 모든 트윗을 계산할 수 있습니까?해시 태그로 짹짹 달기

답변

3

GET 카운트 해시 태그 (#)이 PHP 소스 코드는 트위터

<?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; 
?> 

감사합니다 ..

당신은 특정 해시 태그 나 키워드를 포함하는 트윗을 추적하기 위해 DataSift 같은 서비스를 사용할 수
+3

트위터 API는 요청 당 최대 100 개의 트윗을 제공하기 때문에 좋지만 보이지는 않습니다. 15 또는 16 페이지까지 더 내려 가게하십시오. 따라서 이것이 가장 많으면 1500 개가 넘고, 더있을지라도 더 있습니다. – Sorcy

0

실시간. 그들은 또한 이번 여름에 Historics service을 공개 할 예정이며, 2010 년 1 월까지 검색 할 수 있습니다.