You're here: Home / PHP /

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

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:

<?php
include "DeliciousBrownies.php";

$d = new DeliciousBrownies;
$d->setUsername("myusername");
$d->setPassword("mypassword");
$res = $d->getRecentPosts();

if (!$res) {
    print "something went wrong";
    exit;
}
print_r($res);
/*
outputs something like this:
Array
(
[0] => Array
    (
        [href] => http://www.nashruddin.com/pub/free-php-scripts.html
        [description] => PHP scripts, tips n tricks, code snippets
        [extended] => PHP scripts, tips n tricks, code snippets
        [hash] => 9bfe73757a108356d25c3b8fcb3b3e3a
        [tag] => php-scripts code-snippets php-tips-n-tricks
        [time] => 2008-04-20T05:48:16Z
    )

[1] => Array
    (
        [href] => http://www.nashruddin.com/
        [description] => Computer vision & PHP resources
        [extended] => Nashruddin'd blog, computer vision, php scripts
        [hash] => 057594308f84a4d3b35e0bc08a25af67
        [tag] => computer-vision php-scripts code-snippets
        [time] => 2008-04-20T05:47:55Z
    )    
)
*/
?>

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

<?php
include "DeliciousBrownies.php";

$url   = "http://www.google.com";
$desc  = "Search the web";
$tags  = "search-engine groups";
$notes = "Best search engine, try it!";

$d = new DeliciousBrownies;
$d->setUsername("myusername");
$d->setPassword("mypassword");
$d->addPost($url, $desc, $tags, $notes);
?>

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

<?php
include "DeliciousBrownies.php";

/* setup client */
$d = new DeliciousBrownies;
$d->setUsername("myusername");
$d->setPassword("mypassword");

/* get articles */
$result = mysql_query("select url, desc, tags, notes from articles");

while($row = mysql_fetch_object($result)) {
    $url   = $row->url;
    $desc  = $row->desc;
    $tags  = $row->tags;
    $notes = $row->notes;
    
    /* post 'em all */
    $d->addPost($url, $desc, $tags, $notes);
}
?>

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

Keywords: del.icio.us PHP5 class, del.icio.us web service, manage del.icio.us posts, PHP for del.icio.us

Share:  del.icio.us logo Save to del.icio.us  digg logo Digg this!

comment.gifComments

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

comment.gifAdd your comment

(required, will not be published) (optional)