2010-10-23 59 views
0

我已經開始使用twitter API,並希望通過在特定#hashtag下拉特定用戶的tweet來過濾tweets。任何想法的語法將是什麼,或者如果可能的話?按用戶名和主題標籤篩選高音揚聲器

這是我目前使用的代碼:

<?php 
$username = "TwitterUsername"; // Your twitter username. 
$limit = "5"; // Number of tweets to pull in. 

/* These prefixes and suffixes will display before and after the entire block of  tweets. */ 
$prefix = ""; // Prefix - some text you want displayed before all your tweets. 
$suffix = ""; // Suffix - some text you want displayed after all your tweets. 
$tweetprefix = ""; // Tweet Prefix - some text you want displayed before each tweet. 
$tweetsuffix = "<br>"; // Tweet Suffix - some text you want displayed after each tweet. 

$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" . $limit; 

function parse_feed($feed, $prefix, $tweetprefix, $tweetsuffix, $suffix) { 

$feed = str_replace("&lt;", "<", $feed); 
$feed = str_replace("&gt;", ">", $feed); 
$clean = explode("<content type=\"html\">", $feed); 

$amount = count($clean) - 1; 

echo $prefix; 

for ($i = 1; $i <= $amount; $i++) { 
$cleaner = explode("</content>", $clean[$i]); 
echo $tweetprefix; 
echo $cleaner[0]; 
echo $tweetsuffix; 
} 

echo $suffix; 
} 

$twitterFeed = file_get_contents($feed); 
parse_feed($twitterFeed, $prefix, $tweetprefix, $tweetsuffix, $suffix); 
?> 

非常感謝

+0

任何人有任何想法嗎? – Rob 2010-11-03 21:52:44

回答

0

你只需要改變搜索參數,因爲這(用戶名奈科明和包括hashtag COPD)

http://search.twitter.com/search.atom?q=%23copd+OR+%23nycomed 

我已經在我的主題和作品中測試了這一點。您甚至可以直接在瀏覽器中嘗試。

您可以找到更多信息here