#!/usr/local/bin/php filemtime($cache_file)) { // del.icio.us has been updated since last cache; recache $data = file_get_contents("https://{$username}:{$password}@api.del.icio.us/v1/posts/all?tag=blogroll"); file_put_contents($cache_file, $data); } else { // if there have been no updates, then exit exit; } // STEP TWO: READ CACHED DATA $blogroll = simplexml_load_file($cache_file); foreach ($blogroll->post as $post) { $blogs[] = array( 'name' => $post['description'], 'href' => $post['href'] ); } // sort by name $name = array(); foreach ($blogs as $k => $v) { $name[$k] = $v['name']; } array_multisort($name, SORT_ASC, $blogs); // STEP THREE: GENERATE OPML // start buffering output ob_start(); echo '' . "\n"; ?> PHP Blogroll \n"; } } ?>