del.icio.us - Automatic Blog Post
[Update: I've updated this post with tag support here]
http://del.icio.us has a very useful feature, the daily blog posting, which creates a daily blog post with all the links you tagged during the previous 24 hours. So instead of trying to memorise links and then post when you get a chance, whenever you come across something useful just tag it with del.icio.us as you would normally and at the end of the day or at a time you specify del.icio.us will generate a summarised post for you.
You set this us via the del.icio.us settings page -> del.icio.us -> settings -> daily blog posting.
One snag though, del.icio.us isn't very clear about which blogging API's they support. The interface where you configure the daily blog post is pretty geeky. Under out_url it mentions XML-RPC interface but that is a pretty broad definition. There's several blogging API's out there all XML-RPC based: MetaweblogAPI, Blogger etc. They also don't allow you to test it, you get one shot at configuring it and if it doesn't work the best you can do is configure the job for an hour later and hope for the best.
So after the initial attempt at using the default Metablog.ashx endpoint in Community Server failed I setup a simple HttpHandler last night to just dump out whatever was posted by del.icio.us. It turned out they are using the MetawebblogAPI but for the publish parameter there's a type mismatch with del.icio.us is posting an Int parameter where the CS Metablog were expecting boolean parameter.
So as a quick fix to enable a del.icio.us compatible endpoint I created a new HttpHandler, del.icio.us.ashx, under blogs which just generalised the last parameter to object to allow del.icio.us to successfully create posts here.
Below is the couple of lines of code for my del.icio.us.ashx HttpHandler which just delegates back to the original one. (To use just create a file called del.icio.us.ashx under your blogs folder and add the code below as the content) A cleaner approach if you're using the SDK would be to update and recompile CommunityServer.Blogs but this is a nice & quick no-recompile required addition to enable the del.icio.us daily blog post functionality.
For blogs on dotnet.org.za the url to use for del.icio.is http://dotnet.org.za/blogs/del.icio.us.ashx
Note. This was done after a couple of beers at our year-end lunch and it seems to work but use at own risk.
It also doesn't handle categorising/tagging posts yet. I suspect it's using a non-metablogapi method for setting those but will have to confirm.
<%@ WebHandler Language="C#" Debug="true" Class="CommunityServer.Blogs.Components.Delicious" %>
using System;
using System.Collections;
using System.Configuration;
using System.IO;
using System.Text.RegularExpressions;
using System.Web;
using CommunityServer;
using CommunityServer.Blogs.Components;
using CommunityServer.Components;
using CookComputing.XmlRpc;
namespace CommunityServer.Blogs.Components
{
public interface IDelicious
{ [XmlRpcMethod("metaWeblog.newPost", Description="Makes a new post to a designated blog using the "
+ "MetaWeblog API. Returns postid as a string.")]
string newPost(
string blogid,
string username,
string password,
MetaWeblog.Post post,
object publish);
}
/// <summary>
/// Generalized metablog.newPost endpoint for del.icio.us
/// </summary>
public class Delicious : XmlRpcService, IDelicious
{ public string newPost(
string blogid,
string username,
string password,
MetaWeblog.Post post,
object publish)
{ IMetaWeblog metablog = new MetaWeblog();
bool p = Convert.ToBoolean(publish);
return metablog.newPost(blogid, username, password, post, p);
}
}
}