我试图使用调用一个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
发布于 2020-09-18 05:25:23
在第227期,rakshasa说:
所有命令都应该包含一个目标作为第一个参数,在这种情况下是一个空字符串。
因此,您需要像这样调用,请参阅第一个空字符串:$request = xmlrpc_encode_request("d.multicall2", array("", "main", "d.name="));
https://stackoverflow.com/questions/63922273
复制相似问题