WordPress XML-RPC ASP.NET Client

W

UPDATED – 7th June 2014 – Additional methods added to client, listed below.

WordPress offers an XML-RPC (AKA SOAP for PhP) API for content retrieval and update operations.

I was pretty surprised to find, or actually not find an ASP.NET client for a WordPress feed. Surely somebody must have faced a scenario of needing to export / migrate WordPress content into a .NET app? Apparently not, or if they have they haven’t shared any code 🙁

So I’ve started putting one together and put the code on GitHub and NuGet. It uses the excellent XML-RPC library for .NET by Charles Cook.

So far I’ve focused only on the read operations, as this suited my original goal of content export. Expanding to cover all of the available methods, including write and delete operations will be straightforward. I’m more than happy to take pull requests 🙂

Usage

The WordPress XML-RPC feed by default lives in the root of your WordPress application (/xmlrpc.php), and so at a basic level all you need to provide to download content is a WordPress username / password and the domain that your WordPress instance lives on.

const string baseUrl = "http://www.wordpress.com/";
const string username = "xxx";
const string password = "xxx";

using (var client = new WordPressXmlRpcClient(baseUrl, username, password))
{
     var postId = 23;
     var post = client.GetPost(postId);
     //etc
}

Current API coverage (as of Nuget package 0.5)

The following methods are supported.

  • wp.getPost
  • wp.getPosts
  • wp.getMediaItem
  • wp.getMediaLibrary
  • wp.getTaxonomy
  • wp.getTaxonomies
  • wp.getTerm
  • wp.getTerms
  • wp.getUser
  • wp.getUsers
  • wp.getComment
  • wp.getComments
  • wp.getCommentCount

About the author

Mark Everard

I've worked across the digital industry for the past ten years, helping clients and colleagues across a diverse range of sectors meet numerous digital challenges, specifically focusing on web technologies, digital marketing and content management.

I've worked on large multi-supplier projects and led and managed both in-house and geographically-disperse development teams. And I've always approached my work with a smile on my face.

Mark Everard

I've worked across the digital industry for the past ten years, helping clients and colleagues across a diverse range of sectors meet numerous digital challenges, specifically focusing on web technologies, digital marketing and content management.

I've worked on large multi-supplier projects and led and managed both in-house and geographically-disperse development teams. And I've always approached my work with a smile on my face.

Get in touch