tags:

views:

11

answers:

0

I am trying to get XML-RPC working locally on my joomla site but keep getting the error - Incorrect parameters passed to method: No method signature matches number of parameters

I have been using the debugger in the backend: http://mysite.local/xmlrpc/client.php

Documentation is very poor and I can't even find the correct way to pass params, anyway this is how I have been passing them.

<param><value><string>testuser</string></value></param>
<param><value><string>testpassword</string></value></param>

I also tried

<?xml version="1.0"?>
<methodCall>
   <methodName>testing.login</methodName>
      <params>
    <param><value><boolean>0</boolean></value></param>
    <param><value><string>jackmatt2</string></value></param>
    <param><value><string>jackjack1</string></value></param>
      </params>
</methodCall>

errors everytime.

This is my Joomla code

    <?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.plugin.plugin' );


/**
 * RPC function API
 *
 * @author Jack Matthews
 *
 */
class plgXMLRPCTesting extends JPlugin
{
    function plgXMLRPCTesting(&$subject, $config)
    {
        parent::__construct($subject, $config);
        $this->loadLanguage( '', JPATH_ADMINISTRATOR );
    }

    /**
    * @return array An array of associative arrays defining the available methods
    */
    function onGetWebServices()
    {
        global $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue;

        return array
        (
                'testing.login' => array(
                'function' => 'plgXMLRPCTestingServices::login',
                'docstring' => JText::_('Logs the user into the system'),
                'signature' => array(array($xmlrpcBoolean, $xmlrpcString, $xmlrpcString ))
            )
        );
    }
}


/**
 * Method implementations
 *
 * @author Jack Matthews
 *
 */
class plgXMLRPCTestingServices
{

    function login($username, $password)
    {
        global $mainframe, $xmlrpcerruser, $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue;

        if(!plgXMLRPCBloggerHelper::authenticateUser($username, $password)) {
            return new xmlrpcresp(false, $xmlrpcerruser+1, JText::_("Login Failed"));
        }

        return new xmlrpcresp(true, $xmlrpcerruser+1, JText::_("Login Failed"));
    }

}



/**
 * Helper functions
 *
 * @author Jack Matthews
 *
 */
class plgXMLRPCTestingHelper
{
    function authenticateUser($username, $password)
    {
        // Get the global JAuthentication object
        jimport( 'joomla.user.authentication');
        $auth = & JAuthentication::getInstance();
        $credentials = array( 'username' => $username, 'password' => $password );
        $options = array();
        $response = $auth->authenticate($credentials, $options);
        return $response->status === JAUTHENTICATE_STATUS_SUCCESS;
    }
}