Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Apress.Pro.Drupal.7.Development.3rd.Edition.Dec.2010.pdf
Скачиваний:
73
Добавлен:
14.03.2016
Размер:
12.64 Mб
Скачать

CHAPTER 20 XML-RPC

Built-In XML-RPC Methods

Drupal comes with several XML-RPC methods enabled out of the box. The following sections describe these built-in methods.

system.listMethods

The system.listMethods method lists which XML-RPC methods are available. This is the response a Drupal site will give when queried for which methods it provides:

// Get an array of all the XML-RPC methods available on this server. $url = 'http://example.com/xmlrpc.php';

$methods = xmlrpc($url, array('system.listMethods'));

The response from the server follows:

<?xml version="1.0"?> <methodResponse>

<params>

<param>

<value>

<array>

<data>

<value>

<string>system.multicall</string>

</value>

<value>

<string>system.methodSignature</string>

</value>

<value>

<string>system.getCapabilities</string>

</value>

<value>

<string>system.listMethods</string>

</value>

<value>

<string>system.methodHelp</string>

</value>

<value>

<string>remoteHello.hello</string>

</value>

</data>

</array>

</value>

</param>

</params>

</methodResponse>

461

CHAPTER 20 XML-RPC

The content of $methods is now an array of method names available on the server:

('system.multicall', 'system.methodSignature', 'system.getCapabilities', 'system.listMethods', 'system.methodHelp', 'remoteHello.hello').

system.methodSignature

This built-in Drupal XML-RPC method returns an array of data types. Listed first is the data type of the return value of the function; next come any parameters that a given method expects. For example, the remoteHello.hello method returns a string and expects one parameter: a string containing the name of the client. Let’s call system.methodSignature to see if Drupal agrees:

// Get the method signature for our example method. $url = 'http://example.com/xmlrpc.php';

$signature = xmlrpc($url, 'system.methodSignature', array('remoteHello.hello'));

Sure enough, the value of $signature becomes an array: ('string', 'string').

system.methodHelp

This built-in Drupal XML-RPC method returns the description of the method that is defined in the xmlrpc hook implementation of the module providing the method.

// Get the help string for our example method. $url = 'http://example.com/xmlrpc.php';

$help = xmlrpc($url, 'system.methodHelp', array('remoteHello.hello'));

The value of $help is now a string: it greets XML-RPC clients by name.

system.getCapabilities

This built-in Drupal XML-RPC method describes the capabilities of Drupal’s XML-RPC server in terms of which specifications are implemented. Drupal implements the following specifications:

xmlrpc:

 

specURL

http://www.xmlrpc.com/spec

specVersion

1

faults_interop:

 

specURL

http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php

specVersion

20010516

system.multicall

specURL http://web.archive.org/web/20101015050132/http://www.xmlrpc.com/ discuss/msgReader$1208

specVerson 1

462

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]