knowj Posted September 10, 2008 Share Posted September 10, 2008 I feel pretty stupid asking this but i need to retive xml data from an external source and include it into my cache script. An easier way of putting it would be i need to display: http://api.flickr.com/services/feeds/groups_discuss.gne?id=USERNO@DSD&lang=en-us&format=rss_200 as http://www.myurl.com/flickerfeed.php My minds just hitting a blank at the moment thanks in advance. <?php header("Content-Type: text/xml"); require_once '../includes/class_constants.php'; require_once '../includes/class_cache.php'; $cache = new cache(constants::CACHEDIR); //start output buffer ob_start(); //get cache data $cache->get('flickr.txt', 86400); //check the cache has loaded if (!$cache->load()) { /* start content */ //get file xml from here -> 'http://api.flickr.com/services/feeds/groups_discuss.gne?id=USERNO@DSD&lang=en-us&format=rss_200'; /* end content */ //load header into $header car $cache->newcache(ob_get_contents()); //clean the output buffer ob_clean(); //create the cache $cache->save('flickr.txt'); } ob_end_clean(); echo $cache->export(); ?> Link to comment https://forums.phpfreaks.com/topic/123576-quick-simple-retrive-external-xml-to-cache-on-server/ Share on other sites More sharing options...
knowj Posted September 10, 2008 Author Share Posted September 10, 2008 Solved using: <?php header("Content-Type: text/xml"); require_once '../includes/class_constants.php'; require_once '../includes/class_cache.php'; $cache = new cache(constants::CACHEDIR); //start output buffer ob_start(); //get cache data $cache->get('flickr.txt', 86400); //check the cache has loaded if (!$cache->load()) { /* start content */ passthru("curl http://api.flickr.com/services/feeds/groups_pool.gne?id=USER@FSDF&lang=en-us&format=rss_200"); /* end content */ //load header into $header car $cache->newcache(ob_get_contents()); //clean the output buffer ob_clean(); //create the cache $cache->save('flickr.txt'); } ob_end_clean(); echo $cache->export(); ?> Link to comment https://forums.phpfreaks.com/topic/123576-quick-simple-retrive-external-xml-to-cache-on-server/#findComment-638201 Share on other sites More sharing options...
JonnoTheDev Posted September 10, 2008 Share Posted September 10, 2008 You can simply use the file_get_contents() function to grab the feed and then add some parsing code to format it or use an existing class like http://www.phpclasses.org/browse/package/1820.html Link to comment https://forums.phpfreaks.com/topic/123576-quick-simple-retrive-external-xml-to-cache-on-server/#findComment-638205 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.