Description
Grabs trends from search.twitter.com and counts how many tweets have gone up in the last 10 minutes for each term. Returns data as xml.
Run
| View code [+] |
Create a snippet based on this »
View in new window »
<?php
//header ("content-type: text/xml");
include_snippet(1,"simple_html_dom");
include_snippet(1,"curl_function");
echo "<?xml version='1.0' encoding='UTF-8'?>
<trends>";
$html = str_get_html(curl("http://search.twitter.com"));
foreach($html->find('div#hot') as $div) {
foreach($div->find('a') as $a) {
echo "
<trend>"; echo "
<term>".$a->innertext."</term>";
$url = 'http://search.twitter.com'.$a->href;
echo "
<url>".$url."</url>";
$trend_pg = str_get_html(curl($url));
$trend_size = 0;
foreach($trend_pg->find('div.info') as $result) {
$time = explode("·",$result->innertext);
//echo $time[0];
if (strtotime( $time[0] ) > strtotime( "10 minutes ago" ) ) {
$trend_size++;
}
}
echo "
<strength type='integer'>".$trend_size."</strength>";
echo "
</trend>
";
}
}
echo "</trends>";
?>
Comments (0) | View comments for all versions (0)
Log in if you have a Kogbox account.