//grab twitpic photo built by Mark Goddard of http://0100.tv/ //please leave the credit in, it's most appreciated. You can remove them though, this has no licence attached so it's free to use anyway you like! //insert your twitpic/twitter username $username = "0100"; //this is your twitpic RSS feed... $yourRSS = "http://twitpic.com/photos/".$username."/feed.rss"; //how many images should we display? //i'm not sure what the twitpic limit is but i expect its about ten recent images $noImages = 10; $cacheFor = 5; //how long to cache the file for in minutes $cacheFile = "twitpicCache.rss"; //the cache file to save NOTE: If this doesn't exists PHP will try to automatically create it //lets work out how old the cached file is... $age = time()-filemtime($cacheFile); //if the cached file exists AND the filesize is greater than 1024 bytes (so we know there are no problems with empty cache files) AND the file is younger than the $cacheFile variable then... if(file_exists($cacheFile) && filesize($cacheFile) > 1024 && ($age/60) < $cacheFor) { //if this code is run we ARE using the cache //LIBXML_NOCDATA simply strips out the CDATA tags from the RSS, we dont want it $xml = simplexml_load_file($cacheFile, 'SimpleXMLElement', LIBXML_NOCDATA); } else { //if this code is run we are not using the cache //we can now save the cache file by creating a new DOM Document, loading rhe external RSS and then saving it. $doc = new DOMDocument(); $doc->load($yourRSS); $doc->save($cacheFile); //we then finally load the RSS feed not using the cache just in case it failed $xml = simplexml_load_file($yourRSS, 'SimpleXMLElement', LIBXML_NOCDATA); } $images .= "