Building the Franken-site: Regroup and RPC

After my simple attempts at just including Drupal’s bootstrap and using theme() to get what I wanted failed, I turned to a new pipe to get content from: Drupal’s XML-RPC interface.

I have experience writing Drupal modules, so I did the required reading on hook_xmlrpc, and then got to work.

I added a custom module, redmonk.module. Then, I added a simple method to return the content I wanted (hard coded for now, later I’d make it a little more generic).

function redmonk_shared () {
    return theme('blocks', 'shared');
}

Then I implemented hook_xmlrpc:

function redmonk_xmlrpc () {
    return array ("redmonk.shared"=>"redmonk_shared");
}

Lastly, I built a quick Wordpress plugin, the expansively named drupal.php:

include_once(ABSPATH . WPINC . '/class-IXR.php');

function drupal_get_blocks ($region) {
    $ixrcli = new \
        IXR_Client('http://redmonk.net/more/xmlrpc.php', \
        false,80,15);
    $ret = "no response";
if ($ixrcli->query('redmonk.shared')) {
        $ret = $ixrcli->getResponse();
    }

return $ret;
}

So now, I have an xml-rpc call that returns the chunk of HTML that I need for the Wordpress half of my franken-site. Next, I need to confirm that I can do something similar from Wordpress.