I have created this plugin for wordpress because I wanted to create links in my del.icio.us bookmarks to my own blog posts.
This plugin triggers when I create a blog post and creates a bookmark to the new post using my del.icio.us account.
To use this plugin, you need to have a Wordpress-based blog and a del.icio.us account.
<?php
/*
* Plugin Name: del.icio.us API Client
* Plugin URI: http://soerenlarsen.dk/
* Description: published posts to del.icio.us, uses cURL library!
* Version: 0.2
* Author: slamidtfyn
* Author URI: http://soerenlarsen.dk/
*/
$user = "foo";
$pass = "bar";
function addto_delicious($post_ID)
{
// Get tags
foreach ((get_the_category()) as $cat) {
$tags.= $cat->cat_name . ' ';
}
// Get url
$url = get_permalink($post_ID);
//get description
$description = the_title('', '', false);
// This is the current api url, can be changed by del.icio.us!
$api_url = "https://api.del.icio.us/v1/posts/add";
//this is the data to create a new post
$post_data = "url=".urlencode($url)."&description=".$description.
"&tags=".$tags."&shared=yes&replace=yes";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$api_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_USERAGENT, 'soerenlarsen.dk');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_USERPWD,"$user:$pass");
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$xml = curl_exec ($ch);
curl_close ($ch);
}
add_action('publish_post', 'addto_delicious');
?>
I will continue to work on this plugin, and add more functions. I will post information on updates at my website.
del.icio.uspluginwordpress