March 28th, 2009

WordPress and AS3, a few notes

UPDATE: My WordPress AS3 API is now available.

I’m about halfway through developing my WordPress / AS3 library and I thought I’d note down a few things that have come up during development.

Does anyone know their blogId?

The blogId parameter is required for most wp, mt, and metaweblog calls, yet there is no easy way for a user to find this out (you can’t get your blogId from the WordPress admin interface) – it seems the only way is through a call to wp.getUsersBlogs, using the data from the returned array to match up with the blog url that you are calling. I’ve simplified this process in my API so that whenever you make a webservice method call the api will check to see if a valid blogId is available, and if not, make the wp.getUsersBlogs call for you first.

Inconstencies

WordPress XML-RPC is inconsistent in the way it sends and retrieves some types of data. For example, categories are retrieved using wp.getCategories with the properties categoryName and categoryId, but if you use wp.suggestCategories you get category_name and category_id instead, meaning I have had to write duplicate parsing functions on a few occasions.

Null values

Ak33m’s XML-RPC library (correctly, I assume) serializes null properties to strings with a value of "null". This means  that when you send data to WordPress you can end up with “null” showing up everywhere – (A post with a category of “null” and a tag of “null”, a category with a slug of “null” etc). To avoid this I’ve had to create an IXMLRPC implementation for all of my WordPress structs that converts “null" to an empty string ("") before serialization.

Multiple authors

I haven’t worked out how to make metaweblog.getRecentPosts work with multiple authors. Because you have to authenticate using a username/password to make the call, you can only seem to retrieve posts by that particular author. I’m not sure how to get posts from multi-author blog without having to authenticate separately for each user, which is quite frustrating.

Apart from these minor issues, everything is going along smoothly though – I now have all post, category and page functions working correctly, options and comments to follow.

Posted in flash and tagged , , with no comments »
March 28th, 2009

WordPress and AS3 integration

UPDATE: The AS3 Library for the WordPress API is now available.

Recently I was searching around for an easy way to build a flash front-end for a WordPress managed website for a friend of mine. I was incredibly surprised to find that there doesn’t seem to be a properly integrated ActionScript library available for  WordPress XML-RPC, or if one is available, Google and the Actionscript community don’t seem to know about it.

So I’ve decided to build one.

I’ve had a little experience building ActionScript API libraries before when I was testing the Artbeat API with AQ – the Artbeat library has its flaws (not the least of which is no documentation of any kind), and I’ve learnt a lot from that experience.

My idea is single library that allows you to easily make all of the WordPress, MovableType, and Metaweblog API calls required to integrate flash with WordPress. I’m using Akeem Phillbert’s xml-rpc as3 library, as a base for the XML-RPC calls.

I’ll be posting my progress here as the library develops.

Posted in flash and tagged , , , , with no comments »