PHP : is there any function works like xmlrpc_encode_request?
I've been writing free php script
when i finished u开发者_如何学Gonfortunately i found that xmlrpc_encode_request not work in some hosting
is there a way to active it direct without editing php.ini ? or is there any function works like xmlrpc_encode_request without edit php.ini?
Any help would be much appreciated.
EX:
<?php
$request = xmlrpc_encode_request("method", array(1, 2, 3));
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $request
)));
$file = file_get_contents("http://www.example.com/xmlrpc", false, $context);
$response = xmlrpc_decode($file);
if ($response && xmlrpc_is_fault($response)) {
trigger_error("xmlrpc: $response[faultString] ($response[faultCode])");
} else {
print_r($response);
}
?>
This has been implemented in the XML_RPC2 package. Here's an example:
require_once 'XML/RPC2/Backend/Php/Request.php';
$request = new XML_RPC2_Backend_Php_Request('method', 'utf-8');
$request->setParameters(array(1, 2, 3));
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $request->encode(),
)));
However, it would be easier to use their client as well:
require_once 'XML/RPC2/Client.php';
$client = XML_RPC2_Client::create('http://example.org/xmlrpc');
$response = $client->method(1, 2, 3);
精彩评论