Articles: 843 | Categories: 148   
   
   
Home Articles Contact Us
 
 
 
 
DeliciousBrownies (0 Comments)
Admin: Posted Date: April 4, 2010

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.

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.

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

 

 

 

 

 
 
Add a Comment:
 
(You must be signed in to comment on an article. Not a member? Click here to register)
   
Title:

Comments: