PHP XMLRPC Moodle 函数调用参数与签名不匹配

PHP XMLRPC Moodle function calling parameters do not match signature

我不知道如何正确传递函数所需的参数 core_user_get_users_by_field

下面包含 Moodle 功能文档。

这是 Moodle class 中无法正常工作的功能。

// The getUser function obtains information for a Moodle user identified by its id.
function getUser($user_id) {
// Clear last error.
$this->error = null;

// Create XML for the request. XML must be set properly for this to work.
$request = xmlrpc_encode_request('core_user_get_users_by_field', array(array((string) $user_id)), array('encoding'=>'UTF-8'));

此代码段是引发错误的部分。

array(array((string) $user_id))

FUNCTION DOCUMENTATION--------------------------------------------------- core_user_get_users_by_field

Retrieve users information for a specified unique field - If you want to do a user search, use core_user_get_users()

Arguments field (Required) the search field can be 'id' or 'idnumber' or 'username' or 'email'

General structure

string //the search field can be 'id' or 'idnumber' or 'username' or 'email'

XML-RPC (PHP structure)

[field] => string REST (POST parameters)

field= string

values (Required)

General structure

list of ( string //the value to match ) XML-RPC (PHP structure)

[values] => Array ( [0] => string ) REST (POST parameters)

values[0]= string

我明白了....请参阅下面的代码片段。

$request = xmlrpc_encode_request('core_user_get_users_by_field', array("id", array((string)$user_id)), array('encoding'=>'UTF-8'));