0

I'm trying to connect my app with Drupal. It return me this error: "Something went wrong - -32602 : Server error. Wrong number of method parameters.". I think it should work.

Have anyone any clue what is wrong here?

My code:

set_time_limit(0);
require_once("IXR_Library.php");

// Create the client object
$client = new IXR_Client('http://localhost/drupal6/xmlrpc.php');
//$client->debug=true;
 $username = "admin"; 
 $password = "admin"; 
 $params = array(0,$username,$password,10); 


if (!$client->query('metaWeblog.getRecentPosts', $params)) {
    die('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage());
}

$myresponse = $client->getResponse();
warriorslo
  • 23
  • 3

1 Answers1

0

You are getting an error message (Specification for Fault Code Interoperability, version 20010516) from the XMLRPC endpoint you're communicating with.

It is a defined error code:

-32602 ---> server error. invalid method parameters

The RPC method you requested was found by the server but you passed invalid parameters to it. Contact the support of the service you consume to get a list of all available methods. If your parameters should be available, contact the support and discuss the issue with them.

In your case, double-check what the Drupal manual tells you about the metaWeblog.getRecentPosts XMLRPC Method blogapi_xmlrpcDrupal API:

array(
  'metaWeblog.getRecentPosts',
  'blogapi_metaweblog_get_recent_posts',
  array('array', 'string', 'string', 'string', 'int'),
  t('Returns a list of the most recent posts in the system.'),
),

If this insufficient documentation, look the missing pieces up from within the source-code of Drupal.

For example the first parameter needs to be a string but you use the integer number 0 here.

For more information how you can make use of XMLRPC Introspection please see a releated question / answer: XMLRPC showing -32601 error (using PHP).

I do not know if drupal supports XMLRPC Introspection, but it looks like it does.

Community
  • 1
  • 1
hakre
  • 193,403
  • 52
  • 435
  • 836
  • You mean that first parameter needs to be array right? Anything i try return the same error. Introspections returns bunch of warnings like: "Warning: array_values() expects parameter 1 to be array, string given in E:\xampp\htdocs\test\xmlrpc-discovery.php on line 713 blogger.editPost () Updates the information about an existing post. 3.. blogger.getPost Warning: array_shift() expects parameter 1 to be array, string given in E:\xampp\htdocs\test\xmlrpc-discovery.php on line 712". Nothing useful :( – warriorslo Jun 01 '12 at 21:33
  • No, please see XMLRPC Instrospection. The first entry is the return type, the parameters follow. So the return type is array, not the first parameter. I already formulated that in the answer: You need string, but you have integer. - The errors you see just I think mean that no introspection is available or that the XMLRPC is not standard conform. – hakre Jun 01 '12 at 21:35