PHP 5 Class To Access Del.icio.us Web Service API

Nov 4, 2008 | Tags: WebService | del.icio.us del.icio.us | digg Digg

This class is a set of PHP functions to access del.icio.us web service API. Use this class to easily manage your posts and do some other cool stuff on del.icio.us. Visit my page on del.icio.us to see the result. I posted all of my blog's pages to del.icio.us using this class, taking the pages' <META NAME="keywords"> as the posts' tags.

Requirement:

  • PHP 5 with curl enabled.

Features:

  • Support proxy
  • Access all of del.icio.us API

Usage Samples

Here are some examples. For the full list of available functions, consult reference.html included in the package.

1. Get your recent post at del.icio.us:

Listing 1: listing-1.php

  1. <?php
  2. include "DeliciousBrownies.php";
  3.  
  4. $d = new DeliciousBrownies;
  5. $d->setUsername("myusername");
  6. $d->setPassword("mypassword");
  7. $res = $d->getRecentPosts();
  8.  
  9. if (!$res) {
  10.     print "something went wrong";
  11.     exit;
  12. }
  13. print_r($res);
  14. /*
  15. outputs something like this:
  16. Array
  17. (
  18. [0] => Array
  19.     (
  20.         [href] => http://www.nashruddin.com/pub/free-php-scripts.html
  21.         [description] => PHP scripts, tips n tricks, code snippets
  22.         [extended] => PHP scripts, tips n tricks, code snippets
  23.         [hash] => 9bfe73757a108356d25c3b8fcb3b3e3a
  24.         [tag] => php-scripts code-snippets php-tips-n-tricks
  25.         [time] => 2008-04-20T05:48:16Z
  26.     )
  27.  
  28. [1] => Array
  29.     (
  30.         [href] => http://www.nashruddin.com/
  31.         [description] => Computer vision & PHP resources
  32.         [extended] => Nashruddin'd blog, computer vision, php scripts
  33.         [hash] => 057594308f84a4d3b35e0bc08a25af67
  34.         [tag] => computer-vision php-scripts code-snippets
  35.         [time] => 2008-04-20T05:47:55Z
  36.     )    
  37. )
  38. */
  39. ?>

2. Add a post to del.icio.us:

Listing 2: listing-2.php

  1. <?php
  2. include "DeliciousBrownies.php";
  3.  
  4. $url   = "http://www.google.com";
  5. $desc  = "Search the web";
  6. $tags  = "search-engine groups";
  7. $notes = "Best search engine, try it!";
  8.  
  9. $d = new DeliciousBrownies;
  10. $d->setUsername("myusername");
  11. $d->setPassword("mypassword");
  12. $d->addPost($url, $desc, $tags, $notes);
  13. ?>

3. You can also query your database and post them to del.icio.us. Maybe something similar to this:

Listing 3: listing-3.php

  1. <?php
  2. include "DeliciousBrownies.php";
  3.  
  4. /* setup client */
  5. $d = new DeliciousBrownies;
  6. $d->setUsername("myusername");
  7. $d->setPassword("mypassword");
  8.  
  9. /* get articles */
  10. $result = mysql_query("select url, desc, tags, notes from articles");
  11.  
  12. while($row = mysql_fetch_object($result)) {
  13.     $url   = $row->url;
  14.     $desc  = $row->desc;
  15.     $tags  = $row->tags;
  16.     $notes = $row->notes;
  17.    
  18.     /* post 'em all */
  19.     $d->addPost($url, $desc, $tags, $notes);
  20. }
  21. ?>

Note: you might want to run the script from command line to avoid timeouts. That's it. Download and have fun!

Related Articles

The Downloads

3 Comments

Anung on May 17, 2008:

It's really cool, but how to use this sript on wordpress. Nice resources

LuBoc on Jan 2, 2009:

Thanks a lot, great script

Dasha on May 24, 2009:

Saves lots of time! thank you

Leave a comment

Name (required)
Email (will not be published) (required)
Website

Characters left = 1000

Tags

Newsletter

Send me your new post on:
OpenCV
PHP
Projects
Networking
Regex
to my email:
No, I won't spam your email.

Recent Posts

  1. PHP Script for Converting Relative to Absolute URL
  2. Streaming OpenCV Videos Over the Network
  3. Password Protected Images with PHP
  4. OpenCV Region of Interest (ROI)
  5. Web Based Surveillance System with OpenCV, PHP and Javascript

Popular Posts

  1. OpenCV Eye Detection
  2. OpenCV Examples Part 1
  3. OpenCV Face Detection
  4. OpenCV Eye Tracking
  5. Display Video from Webcam
  6. Phase Correlation in OpenCV
  7. Simple File Server and Downloader Script
  8. Building Dynamic SQL String from Associative Array
  9. Template Matching with OpenCV
  10. Fetching a Web Page From Your PHP Code

About the Author

avatar Cool PHP programmer writing cool PHP scripts. Feel free to contact
Tel. +62 31 8662872
+62 856 338 6017
ICQ 489571630
Skype dede_bl4ckheart
Yahoo dede_bl4ckheart
Google nashruddin.amin