note 73835 added to function.xmlrpc-encode-request
| From: | handco at gmail dot com | Date: | Mon, 12 Mar 2007 16:39:45 +0000 |
| Subject: | note 73835 added to function.xmlrpc-encode-request | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124379@lists.php.net to get a copy of this message | ||
Simple OO client with function Overload :
the php metho test_helloworld is translated to xmlrpc method test.helloworld.
class RpcClient {
private $_methods;
private $_context;
private $_url;
function __construct ($url, $user, $passwd) {
$auth = base64_encode(sprintf('%s:%s', $user,$passwd));
$this->_context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => "Content-Type: text/xml\r\n".
"Authorization: Basic $auth" ,
)
));
$this->_url = $url;
$this->registerMethod ("Test_HelloWorld");
}
function __call($methodName, $params) {
if (array_key_exists($methodName,$this->_methods)) {
// on appelle la fonction RPC
$m = str_replace('_', '.', $methodName);
$r = xmlrpc_encode_request($m,
$params,array('verbosity'=>'newlines_only'));
$c = $this->_context;
stream_context_set_option($c,'http','content',$r);
$f = file_get_contents($this->_url,false,$c);
$resp = xmlrpc_decode($f);
return $resp;
} else {
// on appelle la fonction de l'objet
call_user_method_array($methodName, $this,$params);
}
}
private function registerMethod ($method) {
$this->_methods[$method] = true;
}
}
----
Server IP: 217.174.196.197
Probable Submitter: 81.56.150.194
----
Manual Page -- http://www.php.net/manual/en/function.xmlrpc-encode-request.php
Edit -- https://master.php.net/note/edit/73835
Del: integrated -- https://master.php.net/note/delete/73835/integrated
Del: useless -- https://master.php.net/note/delete/73835/useless
Del: bad code -- https://master.php.net/note/delete/73835/bad+code
Del: spam -- https://master.php.net/note/delete/73835/spam
Del: non-english -- https://master.php.net/note/delete/73835/non-english
Del: in docs -- https://master.php.net/note/delete/73835/in+docs
Del: other reasons-- https://master.php.net/note/delete/73835
Reject -- https://master.php.net/note/reject/73835
Search -- https://master.php.net/manage/user-notes.php