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.