How to send a post to your WordPress blog in C# and ASP.NET

XML-RPC service is used to send posts to WordPress blogs remotely. You can download the corresponding .NET library from here: http://xml-rpc.net

Add this library as a reference in your Visual Studio project. Then define it at the top of your code:

using CookComputing.XmlRpc;

The rest of the code is below.

public void wordpressPost()
{
    blogInfo newBlogPost = default(blogInfo);
    newBlogPost.title = "This is title";
    newBlogPost.description = "Post goes here";

    IgetCatList categories = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));
    XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)categories;

    clientProtocol.Url = "http://www.yourblog.com/xmlrpc.php"; //your blog address comes here
    string result = null;

    result = "";

    result = categories.NewPage(1,
    "admin", //your blog admin user id
    "yourpassword", //your blog admin password
    newBlogPost,
    1);
}

public struct blogInfo
{
    public string title;
    public string description;
}

public interface IgetCatList
{
    [CookComputing.XmlRpc.XmlRpcMethod("metaWeblog.newPost")]
    string NewPage(int blogId, string strUserName,
    string strPassword, blogInfo content, int publish);
}

6 thoughts on “How to send a post to your WordPress blog in C# and ASP.NET

Leave a Reply