Using XML-RPC as the data gateway:

WordPress as of 2.2 already offers xml-rpc based access, so this cuts down the amount of outside code you need to write, however for anyone who has gone digging through the php will notice that while they include several different API’s, there is some key functionality that is missing in order to really take advantage of Flex – Flash based RIA solutions.
A list of posts ordered by category: In standard wordpress access, this is typically encountered when clicking on a live link generated from a category which gives you an archive view of all posts that belong to that category. Thinking about this from both the RIA and the user’s point of view, more often than not I don’t want to read or have to open every single post that belongs to a category -especially if the blogger is mature and has 100+ posts over 2+ years. The user experience I want to generate from this, is to be able to open a list of posts that belong to that category then choose which one(s) do I want to open if any.

Gaining Application access: I’ll be the first to tell you that I have little to zero experience with php. So I scoured other sources to find out if this capability problem was already solved by someone else trying to do something similar. What I found was, something very close but was written as a plugin (thanks goes out to a post: list of posts by category for wordpress), and not part of the xml-rpc domain. A hack job was in order to customize the access point.

First off is to add the method signature to the method array in the constructor.

“custom.getPostListByCategory”=> getPostListByCategory,

Second is the function itself, from the best of what I could make out of php syntax and API documentation on, it makes use of the wpdb (database) functions to write a SQL query. The query is written to return the information about posts (id, title, date) when compared to its category and sorted by title. This is then processed as objects of an array to reformat the key:value pairs so it can be easily transformed to a common xml schema, as defined in the super class. Now, this probably could be written a little more elegantly instead of using temporary variables, but I’m of the opinion that it works where something didn’t before.

function getPostListByCategory($args) {
$blog_id        = (int) $args[0];
$username       = $args[1];
$password       = $args[2];

if(!$this->login_pass_ok($username, $password)) { return($this->error); }

global $wpdb, $post;
$tp = $wpdb->prefix;

$sort_code = ‘ORDER BY cat_name ASC, post_date DESC’;
$last_posts = (array)$wpdb->get_results(
SELECT post_date, ID, post_title, cat_name, cat_ID
FROM {$tp}posts, {$tp}post2cat, {$tp}categories
WHERE {$tp}posts.ID = {$tp}post2cat.post_id
AND {$tp}categories.cat_ID = {$tp}post2cat.category_id
AND post_status = ‘publish’
AND post_type != ‘page’
AND post_date < NOW()

if (empty($last_posts)) { return NULL; }

$post_struct =Array();

$used_cats = array();
$i = 0;
foreach ($last_posts as $posts) {
if (in_array($posts->cat_name, $used_cats)) { unset($last_posts[$i]); }
else { $used_cats[] = $posts->cat_name; }

$post_rewrite =Array(
“dateCreated”   => new IXR_Date($posts->post_date),
“postid”                => $posts->ID,
“title”   => $posts->post_title,
“categoryName”  => $posts->cat_name,
“categoryId”    => $posts->cat_ID

$post_struct[] =$post_rewrite;

return $post_struct;

Or grab the file: R-click, Save, Rename from .txt to .php: Customized XML-RPC Gateway