首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何调用d.multicall2

如何调用d.multicall2
EN

Stack Overflow用户
提问于 2020-09-16 14:30:26
回答 1查看 210关注 0票数 0

我试图使用调用一个API。下面是我想要撤回的API:https://rtorrent-docs.readthedocs.io/en/latest/cmd-ref.html#term-d-multicall2

到目前为止,我做了以下几点:

代码语言:javascript
复制
<?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);

结果:

代码语言:javascript
复制
string(310) " faultCode -501 faultString Unsupported target type found. "

使用xmlrpc进行示例调用:

代码语言:javascript
复制
rtxmlrpc --repr d.multicall2 '' tagged d.hash= d.name= d.custom=category

我不明白为什么我会犯这个错误

rTorrent版本: 0.9.7/0.13.7

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-18 05:25:23

第227期,rakshasa说:

所有命令都应该包含一个目标作为第一个参数,在这种情况下是一个空字符串。

因此,您需要像这样调用,请参阅第一个空字符串:$request = xmlrpc_encode_request("d.multicall2", array("", "main", "d.name="));

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63922273

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档