我需要创建简单的php脚本来获取我的rtorrent实例的一些信息…我尝试了很多代码,但我从来没有给出响应...
这是我最后一次测试
ini_set('display_errors', 1);
error_reporting(E_ALL);
function do_call($host, $port, $request) {
$url = "http://$host:$port";
$header[] = "Content-type: text/xml";
$header[] = "Content-length: ".strlen($request);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$data = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
return $data;
}
}
$host = '127.0.0.1';
$port = 10001;
$request = xmlrpc_encode_request("system.listMethods()", null);
$response = do_call($host, $port, $request);
var_dump($response);你有没有简单的测试代码?
发布于 2015-02-13 22:44:16
这是PHP-XMLRPC中的一个错误。
但是,您可以替换您的线路:
$data = curl_exec($ch);通过以下方式:
$data = xmlrpc_decode(str_replace('i8>', 'i4>', curl_exec($ch)));这应该会像预期的那样工作。
https://stackoverflow.com/questions/27613048
复制相似问题