The del.cio.us "daily blog post" functionality also don't allow mutiple tags so you're restricted to a single tag per post. And instead of a string tag they also expect you to enter a category id so you'll need to get this from your blog first. (One way to get this is to open your blog control panel, browse to the tag/key words section and just hover over the desired tag. The categoryId in the querystring is the value we're interested in)
Besides all that, still a pretty useful feature. Below the code for the del.icio.us httphandler. Drop into blogs folder to enable "daily blog post" support. Download here.
<%@ 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
{ // http://www.sixapart.com/developers/xmlrpc/movable_type_api/mtsetpostcategories.html
[XmlRpcMissingMapping(MappingAction.Ignore)]
public struct Category
{ public int categoryId;
public object isPrimary;
}
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);
[XmlRpcMethod("mt.setPostCategories", Description = "Sets the categories for a post.")]
bool setPostCategories(
int postId,
string username,
string password,
Category[] categories);
}
/// <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);
}
public bool setPostCategories(
int postid,
string username,
string password,
Category[] categories)
{ if(ValidateUser(username,password)) {
WeblogPost wp = WeblogPosts.GetPost(postid, false, false, false);
if(wp == null)
throw new XmlRpcFaultException(0, "Post not found");
Weblog weblog = Weblogs.GetWeblog(wp.SectionID,true);
// No exception, redirect
Permissions.AccessCheck(weblog,Permission.Post, CSContext.Current.User);
string[] splits =
Array.ConvertAll<Category, string>(categories,
delegate(Category c) { try{ return PostCategories.GetCategory(c.categoryId, wp.SectionID).Name;
}
// CategoryId don't exist just ignore it.
catch (NullReferenceException){ return null;
}
});
wp.Categories = splits;
WeblogPosts.Update(wp);
return true;
}
throw new XmlRpcFaultException(0,"Invalid username/password");
}
private bool ValidateUser(string username, string password)
{ if(String.IsNullOrEmpty(username))
throw new XmlRpcFaultException(0, "No username");
try { User u = new User();
u.Username = username;
u.Password = password;
CommunityServer.Components.LoginUserStatus status = Users.ValidUser(u);
if(status == CommunityServer.Components.LoginUserStatus.Success) { CSContext.Current.User = Users.GetUser(-1,u.Username,false,false);
return true;
}
return false;
}
catch{ throw new XmlRpcFaultException(0, "Membership unavailable");
}
}
}
}