Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Created August 2, 2010 06:27
Show Gist options
  • Select an option

  • Save thinkphp/504205 to your computer and use it in GitHub Desktop.

Select an option

Save thinkphp/504205 to your computer and use it in GitHub Desktop.
$url = 'http://twitter.com/statuses/public_timeline.rss';
$twitterdata = get($url);
preg_match_all("/<description>([^<]+)<\/description>/msi",$twitterdata,$descriptions);
$descriptions[1] = preg_replace("/^([\w]+)\:/","<strong>$1</strong>",$descriptions[1]);
foreach($descriptions[1] as $key=>$desc) {
if($key == 0) {
continue;
}
//assemble REST call and curl the result
$url = 'http://www.google.com/uds/GlangDetect?callback=' .
'feedresult&context='. $key . '&q=' . urlencode($desc) .
'&key=notsupplied&v=1.0';
//get the language
$language = get($url);
preg_match("/\"language\":\"([^\"]+)\"/",$language,$resp);
echo" <!-- ";
print_r($language);
echo' -->';
//write out the list item
echo'<li class="'.$resp[1].'">'.$desc.' is <span>'.$resp[1].'</span></li>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment