2011-07-04 32 views
0

我正在開發Twitter應用程序,並遇到我無法解決的問題。請問你能幫幫我嗎? 該應用程序用於宣傳品牌。我們需要使用標籤來計算每條推文,並給推文#50000的作者一個價格。我們如何從Twitter API獲取這些數據並識別鳴叫#50000?謝謝你的幫助!使用標籤計數推文

我們使用PHP和MySQL。

+0

請分享你到目前爲止的嘗試。用於Ruby引用的downvoted的 –

回答

1

我首先查看phirehose,它可以讓你獲得推文。您也可以使用Ruby Twitter Gem,這是相當有據可查的,如果您對紅寶石感覺舒適,似乎易於使用。

+0

。 OP明白表示他們使用PHP和MySQL – cspray

0

昨晚我正在看這個。您可以請求網址ie。 http://search.twitter.com/search.json?q=%23hashtag

(這裏的文檔頁面http://dev.twitter.com/doc/get/search

而上說5分鐘的cron腳本,讓你拿到了最後的鳴叫ID的記錄,傳遞,爲搜索URL since_id參數,同時還保持計數你有多少鳴叫計數,可選存儲每個鳴叫,以供參考表...這就是我的2美分

+0

它只會列出最近標記的帖子......他需要設置cron作業來監視這些推文,即使這樣,50000實際上也不會是50000推文... –

+0

流媒體API將更準確,因爲它會在寫入時返回推文。搜索API通過舊推文,我不認爲這是@abotella想要實現的。 – AlexBrand

1

爲獲取計數包括hashtag(#)這個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; 
?> 

謝謝..