I definitely didn’t want to insult your judgment on what library to use and I’m sure you know 1,000 times more than I do about XML-RPC.
The negative stuff I got about PHP-XML-RPC came from their home page:
http://phpxmlrpc.sourceforge.net/.
Our version is labeled internally as V 1.158:
// by Edd Dumbill (C) 1999-2002
// <[email protected]>
// $Id: xmlrpc.inc,v 1.158 2007/03/01 21:21:02 ggiunta Exp $
// Copyright (c) 1999,2000,2002 Edd Dumbill.
2.2.1 was released in March of 2008.
1.2.1 was released in September of 2005.
Updating would take care of the problems I mentioned, but not my trouble with the package. Honestly, I wrestled with it (starting from your code) for two full days and all I was trying to do was to send the authentication code to the Mollom server and ask for the server list. By the time I finished, I concluded that the easiest way to make it work would be to hard-code the XML strings. I couldn’t get anything to work without converting every individual data item to an xmlrpcval object. Even after doing that, Mollom wants the 4 parts of the authentication code as a struct and PHP-XML-RPC seemed to want to send them as individual params unless I used addStruct with a literal array:
$val = new xmlrpcval();
//$data = new xmlrpcval($this->_mollom_authenticate());
$data = $this->_mollom_authenticate();
$val->addStruct( array(
"public_key" => new xmlrpcval($data['public_key']),
"time" => new xmlrpcval($data['time']),
'hash' => new xmlrpcval($data['hash']),
'nonce' => new xmlrpcval($data['nonce'])
));
$msg = new xmlrpcmsg('mollom.getServerList', array($val));
//$msg = new xmlrpcmsg('mollom.getServerList', $data);
//return $thic->client->sent(_mollom_authenticate());
return $this->client->send($msg);
The commented lines are just a few of the many things that didn’t work. The code above did work, but I never did find a way to put the addStruct code inside the _mollom_authenticate function where it belongs. Nor did I find a way to get the data out of what was returned from the send. Neither the client class nor the xmlrpcresp class has any member functions to retrieve the data and after looking at Incutio, a lot of the PHP-XML-RPC classes seem unnecessary, as does the constant conversion of things back and forth between the various classes and php objects (e.g. php_xmlrpc_decode($xmlrpc_val, $options=array()) .
Maybe I’m missing some key understanding of the PHP-XML-RPC code, but I spent a lot of time looking at it and trying things and got pretty much nowhere. Using Incutio, I’ve almost completed the Mollom service class since I posted that message late yesterday. Everything worked just like I thought it would. And Incutio, BTW, claims complete support of the XML-RPC protocol. It’s used in WordPress and most other blogging packages, and it seems we’d have heard about it if it had any serious security issues. I couldn’t find anything via google except a warning message from you on the forums a while back
This code, using Incutio, has done everything I need to implement my class:
function _dispatch($method, $data) {
$mollom_client->query('mollom.' . $method, $data + $this->_mollom_authenticate());
if ( ! $mollom_client->getErrorCode()) {
return $mollom_client->getResponse();
} else {
$this->errors = array('errorCode'=>$mollom_client->getErrorcode(), 'errorMessage'=>$mollom_client->getErrorMessage();
}
}
$data is a plain PHP associative array and the function returns a PHP associative array with all the data in it. If there’s an equally easy PHP-XML-RPC version of this function, I’ll be glad to switch.