Posted By

bitcrumb on 09/04/07


Tagged

xml blog links api delicious opml generate blogroll


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


Generate blogroll from del.icio.us links


 / Published in: PHP
 

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

  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. ?>

Report this snippet  

You need to login to post a comment.