To have an xmlrpc fault response programatically generated by the server, the php function registered as method handler must return an array containing a FaultCode and a FaultString members.
function $myfunc($methodname, $vals, $extra_data)
{
...
return array('faultCode' => 666, 'faultString' => 'DOH!');
}
PHP.mk документација
xmlrpc_server_register_method
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Патека
function.xmlrpc-server-register-method.php
Локална патека за оваа страница.
Извор
php.net/manual/en
Оригиналниот HTML се реупотребува и локално се стилизира.
Режим
Прокси + превод во позадина
Кодовите, табелите и белешките остануваат читливи во истиот тек.
Референца
function.xmlrpc-server-register-method.php
xmlrpc_server_register_method
Референца за `function.xmlrpc-server-register-method.php` со подобрена типографија и навигација.
xmlrpc_server_register_method
(PHP 4 >= 4.1.0, PHP 5, PHP 7)
xmlrpc_server_register_method — Register a PHP function to resource method matching method_name
= NULL
Ги ескејпува специјалните знаци во стринг за употреба во SQL изјава
Оваа функција е ЕКСПЕРИМЕНТАЛНАОднесувањето на оваа функција, нејзиното име и околната документација може да се променат без претходна најава во идно издание на PHP. Оваа функција треба да се користи на ваш сопствен ризик.
Ги ескејпува специјалните знаци во стринг за употреба во SQL изјава
Оваа функција моментално не е документирана; достапна е само листата со аргументи.
Белешки од корисници Управување со PDO конекции
giunta точка gaetano на sea-aeroportimilano точка it ¶
19 години пред
nyvsld на gmail dot com ¶
20 години пред
prototype of registered function:
function method_impl(string $method_name, array $params, array $user_data);
$method_name
the public method name, known by calling client
$params
parameters specified by calling client
$user_data
any local data, passed by `xmlrpc_server_call_method'
Регистрирајте PHP функција за метод на ресурс што одговара на method_name ¶
20 години пред
Remember that you can't do like Chrigu and Nate said if you want to add methods from a static class (Hence you can't create any instances of it).
A workaround is to create lambda functions calling the
methods:
// Our static handler class
static class MyHandler
{
public function getPrice($item)
{
$prices = array("apple" => 4, "orange" => 5);
return $prices[$item];
}
public function buy($item, $number)
{
$price = self::getPrice($item) * $number;
do_thing_to_sell_the_item();
return $price;
}
}
// Use reflection to get method names and parameters
$mirror = new ReflectionClass("MyHandler");
foreach ($mirror->getMethods() as $method)
{
// Create new "lambda" function for each method
// Generate argument list
$args = array();
foreach ($method->getParameters() as $param)
{
$args[] = '$'.$param->getName();
}
$args = implode(',', $args);
// Generate code
$methodname = $method->getName();
$code = "return {$real_class}::{$methodname}({$args});";
// Create function, retrieve function name
$function_name = create_function($args, $code);
// Register the function
xmlrpc_server_register_method($myserver, $methodname, $function_name);
}
Анонимен ¶
пред 23 години
Here is an example how to register a class methode:
xml_rpc_server_register_methode($xmlrpc_server, "foo", array(&$bar, "foo_func"));
where $bar is the instance of your class and foo_func a methode of this class. Don't forget the '&'!
hope this may be useful...
Chrigu
eiriks на hollowmatrix точка com ¶
пред 5 години
Note 1: even if you add introspection data via calls to `xmlrpc_server_register_introspection_callback` or `xmlrpc_server_add_introspection_data`, the server will not validate for you the number or type of received parameters.
This means that you have to implement all required validation of the received parameters in your php function.
Note 2: take care about dealing with base64 and datetime values in the received parameters: those are not automatically transformed into php scalar values, but into stdClass objects with members `xmlrpc_type` and `scalar`
giunta dot gaetano на gmail dot com ¶
20 години пред
To register a callback to a 'static' function within the same class, consider a syntax like the following:
<code>
$callback = array (__CLASS__, "my_function_name");
xmlrpc_server_register_method($xmlrpc_server, "my_function", $callback);
</code>
Doing it this way makes it easier to rename your class later.
dante на lorenso dot com ¶
пред 22 години
In case its not completely obvious what Chrigu meant,
You can register a method inside your class by doing the following:
xml_rpc_server_register_methode($xmlrpc_server, "myClientCall", array(&$this, "handleClientCallFunc"));
where $this == the magic class $this. =)