如何调用d.multicall2
How to call d.multicall2
我正在尝试使用 PHP xml-rpc 调用 API。这是我要检索的 API:https://rtorrent-docs.readthedocs.io/en/latest/cmd-ref.html#term-d-multicall2
到目前为止,我做了以下工作:
<?php
$username "test";
$password = "test";
function do_call($username, $password, $request) {
$url = "https://$username:$password@example.com:32491/RPC2";
$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;
}
}
//$request = xmlrpc_encode_request("download_list", array()); //Give torrents hash
$request = xmlrpc_encode_request("d.multicall2", array("main", "d.name="));
$response = do_call($username, $password, $request);
var_dump($response);
结果:
string(310) " faultCode -501 faultString Unsupported target type found. "
使用 xmlrpc 的示例调用:
rtxmlrpc --repr d.multicall2 '' tagged d.hash= d.name= d.custom=category
我不明白为什么会出现此错误
rTorrent 版本:0.9.7/0.13.7
在issue 227罗刹说:
All commands are supposed to include a target as the first parameter,
in this case an empty string.
所以你需要像这样调用看到第一个空字符串:$request = xmlrpc_encode_request("d.multicall2", array("", "main", "d.name="));
我正在尝试使用 PHP xml-rpc 调用 API。这是我要检索的 API:https://rtorrent-docs.readthedocs.io/en/latest/cmd-ref.html#term-d-multicall2
到目前为止,我做了以下工作:
<?php
$username "test";
$password = "test";
function do_call($username, $password, $request) {
$url = "https://$username:$password@example.com:32491/RPC2";
$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;
}
}
//$request = xmlrpc_encode_request("download_list", array()); //Give torrents hash
$request = xmlrpc_encode_request("d.multicall2", array("main", "d.name="));
$response = do_call($username, $password, $request);
var_dump($response);
结果:
string(310) " faultCode -501 faultString Unsupported target type found. "
使用 xmlrpc 的示例调用:
rtxmlrpc --repr d.multicall2 '' tagged d.hash= d.name= d.custom=category
我不明白为什么会出现此错误
rTorrent 版本:0.9.7/0.13.7
在issue 227罗刹说:
All commands are supposed to include a target as the first parameter, in this case an empty string.
所以你需要像这样调用看到第一个空字符串:$request = xmlrpc_encode_request("d.multicall2", array("", "main", "d.name="));