Building the Franken-site: It's Alive!
After managing to fetch the content I wanted from Drupal into a Wordpress page via a custom XML-RPC call, I needed to figure out how to get recent posts out of Wordpress and onto a Drupal page.
Naturally RSS is a pretty decent way to accomplish this sort of thing, but I did not really want to mess with creating a custom feed just for this information. So I fell back to Wordpress’s XML-RPC api. Wordpress supports the MetaWeblog api, which has an api which fitted my needs exactly:
metaWeblog.getRecentposts (n)
So, I added a couple methods to my redmonk.module for Drupal:
function redmonk_monkinetic_posts_call ($num) {
$rpc_result = xmlrpc ("http://redmonk.net/xmlrpc.php",
"metaWeblog.getRecentPosts",
"myblog","myusername","mypwd", $num);
return $rpc_result;
}
function redmonk_monkinetic_posts ($num) {
$posts = redmonk_monkinetic_posts_call ($num);
$retstr = "<dl class='nodes'>\n";
foreach ($posts as $post) {
$retstr .= "<dt><a href='" . $post['link'] . "'>" .
$post['title'] . "</a></dt>\n";
$retstr .= "<dd>" . $post['description'] . "</dd>\n";
}
$retstr .= "</dl>\n";
return $retstr;
}
The call goes into a Drupal template in the mornal manner:
print redmonk_monkinetic_posts (1);
Bingo!
So now all that remains is to clean up the plugin/module code on each side, and implement the new template. I had initially hoped for a more “integrated” way to work between the two, but the XML-RPC approach was remarkably simple, will be quite flexible, and will survive upgrades to both platforms.
