We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Is there any objection to my using the Incutio xml-rpc lib for Mollom? It’s very lightweight (which is all I need, since I just need a very simple client). It loads a little faster and is infinitely easier to use than the current PHP-XML-RPC library. Also, Incutio is the library behind the WordPress Mollom plugin so I can use the examples in that plugin.

    Drupal’s plugin uses a custom PHP5 Mollom class that uses just cURL so it’s useless for MODx.

    I was literally able to do in 20 minutes with Incutio what I spent two days trying to bang together with PHP-XML-RPC (and never fully succeeded).

    About 20 lines of confusing code in PHP-XML-RPC boiled down to this using Incutio:

    $this->client = new IXR_Client($url);
    $response = $this->client->getResponse($method, $myArray);



    With Incutio, there’s no messing around with addStruct, addScalar, and the various objects and methods like xmlrpcval, xmlrpcmsg, xmlrpcresponse, serialize, php_xmlrpc_encode, phpxmlrpc_decode, etc. You just hand it a PHP associative array to send and it returns the value in a string and sets an error object if there’s an error.

    I think PHP-XML-RPC has more bells and whistles, but our current version is reportedly out-of-date, uses eval(), has security vulnerabilites, and conflicts with other xmlrpc libs on some servers.

      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: BobRay at Feb 08, 2009, 03:57 PM

      Is there any objection to my using the Incutio xml-rpc lib for Mollom? It’s very lightweight (which is all I need, since I just need a very simple client). It loads a little faster and is infinitely easier to use than the current PHP-XML-RPC library. Also, Incutio is the library behind the WordPress Mollom plugin so I can use the examples in that plugin.

      Drupal’s plugin uses a custom PHP5 Mollom class that uses just cURL so it’s useless for MODx.

      I was literally able to do in 20 minutes with Incutio what I spent two days trying to bang together with PHP-XML-RPC (and never fully succeeded).
      You can use whatever you want to create components in MODx, but your evaluation of Incutio is opposite of mine; I chose specifically not to use it because it was so, ironically, out-of-date.

      Quote from: BobRay at Feb 08, 2009, 03:57 PM

      About 20 lines of confusing code in PHP-XML-RPC boiled down to this using Incutio:

      $this->client = new IXR_Client($url);
      $response = $this->client->getResponse($method, $myArray);


      With Incutio, there’s no messing around with addStruct, addScalar, and the various objects and methods like xmlrpcval, xmlrpcmsg, xmlrpcresponse, serialize, php_xmlrpc_encode, phpxmlrpc_decode, etc. You just hand it a PHP associative array to send and it returns the value in a string and sets an error object if there’s an error.
      I think you must have confused yourself, because in the sample class I wrote, the code boiled down to essentially the same thing:
      $this->client = new xmlrpc_client($url);
      $response = $this->client->send($msgArray);
      

      ...and being able to support the all the data types of the XML-RPC protocol is not really what I would consider "messing around"; native PHP types simply do not exist for all of the possible types you may need to support with XML-RPC web services.

      Quote from: BobRay at Feb 08, 2009, 03:57 PM

      I think PHP-XML-RPC has more bells and whistles, but our current version is reportedly out-of-date, uses eval(), has security vulnerabilites, and conflicts with other xmlrpc libs on some servers.
      I think you need to present some information here, because our version is up-to-date; in fact it was updated last year. In contrast, and if I’m not mistaken, it’s been six years since Incutio was updated and certainly doesn’t seem to be maintained anymore. With the potential security vulnerabilities in any XML-RPC implementation, I immediately removed it from consideration.

      There are other factors for choosing phpxmlrpc, and it certainly shouldn’t conflict with the native xmlrpc extensions (but if it does, that is something I will want addressed for the core services that will be made available in XML-RPC, and other protocols; we can create a wrapper class to load it only if the extension is not available like I’m going to do with the PCLZIP library before beta.

      Anyway, I’m just curious where you got this information on the software I’ve chosen, cause it is not consistent with my research and experience with the available XML-RPC libraries.
        • 3749
        • 24,544 Posts
        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 wink

        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.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting