【问题标题】:How to connect to Drupal 6 with xml-rpc如何使用 xml-rpc 连接到 Drupal 6
【发布时间】:2012-06-01 19:54:10
【问题描述】:

我正在尝试将我的应用程序与 Drupal 连接。它返回给我这个错误:“出了点问题 - -32602:服务器错误。方法参数的数量错误。”。我认为它应该有效。

有人知道这里出了什么问题吗?

我的代码:

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();

【问题讨论】:

    标签: php drupal xml-rpc


    【解决方案1】:

    您正在从与之通信的 XMLRPC 端点获得error message (Specification for Fault Code Interoperability, version 20010516)

    这是一个已定义的错误代码:

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

    服务器找到了您请求的 RPC 方法,但您向其传递了无效参数。请联系您使用的服务的支持人员以获取所有可用方法的列表。如果您的参数应该可用,请联系支持人员并与他们讨论问题。

    在您的情况下,请仔细检查 Drupal 手册告诉您的有关 metaWeblog.getRecentPosts XMLRPC 方法 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.'),
    ),
    

    如果文档不足,请从 Drupal 的源代码中查找缺失的部分。

    例如第一个参数需要是一个字符串,但你在这里使用整数0

    有关如何使用 XMLRPC Introspection 的更多信息,请参阅相关问题/答案:XMLRPC showing -32601 error (using PHP)

    我不知道drupal 是否支持XMLRPC Introspection,但看起来确实支持。

    【讨论】:

    • 你的意思是第一个参数需要是数组对吗?我尝试的任何东西都会返回相同的错误。 Introspections 返回一堆警告,例如:“警告:array_values() 期望参数 1 是数组,字符串在 E:\xampp\htdocs\test\xmlrpc-discovery.php 中的第 713 行 blogger.editPost () 更新有关现有帖子。3 .. blogger.getPost 警告:array_shift() 期望参数 1 是数组,字符串在 E:\xampp\htdocs\test\xmlrpc-discovery.php 的第 712 行给出。没什么用:(
    • 不,请参阅 XMLRPC Instrospection。第一项是返回类型,后面是参数。所以返回类型是数组,不是第一个参数。我已经在答案中阐述了这一点:你需要字符串,但你有整数。 - 我认为您看到的错误意味着没有可用的自省或 XMLRPC 不符合标准。
    猜你喜欢
    • 2012-02-16
    • 2018-07-03
    • 2014-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-27
    • 1970-01-01
    相关资源
    最近更新 更多