Generate blogroll from del.icio.us links


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $username = 'your_username';
  3. $password = 'your_password';
  4. $cache_file = '/tmp/blogroll.xml';
  5.  
  6. // check for updates to del.icio.us account
  7. $update = simplexml_load_file("https://{$username}:{$password}@api.del.icio.us/v1/posts/update");
  8.  
  9. if (strtotime($update['time']) > filemtime($cache_file))
  10. {
  11. // del.icio.us has been updated since last cache; recache
  12. $data = file_get_contents("https://{$username}:{$password}@api.del.icio.us/v1/posts/all?tag=blogroll");
  13. file_put_contents($cache_file, $data);
  14. }
  15.  
  16. // read links from cached del.icio.us data
  17. $blogroll = simplexml_load_file($cache_file);
  18.  
  19. foreach ($blogroll->post as $blog)
  20. {
  21. echo '<a href="' . htmlentities($blog['href']) . '">';
  22. echo htmlentities($blog['description']);
  23. echo "</a><br />\n";
  24. }
  25. ?>

URL: http://benramsey.com/archives/generating-opml-from-delicious/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.