Fetching Dilbert Comic stripts from rss feed
This is a php script to fetch dilbert images out of a feedburner feed. Its a quick an dirty implementation it works and I'm sure there are bug's in it.
Enjoy! :D ... ah you can find the testside here -> testside or download it here
Enjoy! :D ... ah you can find the testside here -> testside or download it here
<\?php
/**
* Make Sure XML is cached for couple of minutes
*/
$tmpfile = '/tmp/dilbert.rss';
$gap = 60*60*1; # 1 hour(s)
if(file_exists($tmpfile)===true && (filemtime($tmpfile)+$gap)>time())
{
# Use locale cached dilbert Content
$xmlStr = file_get_contents($tmpfile);
}
else
{
# Reload Cached DilbertFeed
if(!file_exists($tmpfile))
{
touch($tmpfile);
}
$xmlStr = file_get_contents('http://feeds2.feedburner.com/DilbertDailyStrip?format=rss');
file_put_contents($tmpfile,$xmlStr);
}
$xml = new simpleXMLElement($xmlStr);
$content = $xml->xpath('//item');
\?>
Permalink Kommentare[0] Tags: php simple xml dilbert xpath coding labs rss








