gpt4 book ai didi

php - 来自 rtorrent 的空 xmlrpc 响应

转载 作者:搜寻专家 更新时间:2023-10-31 20:40:56 27 4
gpt4 key购买 nike

我想编写自己的 rTorrent WebUI,并使用 xmlrpc 完成我的第一步。但不知何故,它并没有真正起作用......

这是我为 HTTP POST 请求编写的函数:

function request($method, $args) {
$data = xmlrpc_encode_request($method, $args);
$ch = curl_init('http://#####/RPC2/');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = xmlrpc_decode(curl_exec($ch));
curl_close($ch);
return $response;
}

现在获取种子列表...

$data['hash'] = request('download_list',null);
print_r($data);
Array
(
[hash] => Array
(
[0] => 0CF0C7F75D18281AE7C65309F6B798CEB149BCB8
[1] => 8CAA3ED5CB29999A6DA84739FDFF2D6B04489833
)

)

...并请求每个种子/哈希的信息(reference 可能的方法)。

foreach ($data['hash'] as $index => $hash) {
echo "d.get_name: "; print_r(request('d.get_name', $hash));
echo "\nd.get_base_path: "; print_r(request('d.get_base_path', $hash));
echo "\nd.get_hash: "; print_r(request('d.get_hash', $hash));
echo "\nd.is_active: "; print_r(request('d.is_active', $hash));
echo "\nd.get_down_total: "; print_r(request('d.get_down_total', $hash));
echo "\nd.get_up_total: "; print_r(request('d.get_up_total', $hash));
echo "\nd.get_size_bytes: "; print_r(request('d.get_size_bytes', $hash));
}

应显示有关与哈希匹配的种子的信息,但只有少数有效。

d.get_name:       [Anime-Koi] Tokyo Ravens - 01v2 [h264-720p][9E02D3C9].mkv
d.get_base_path: /data/rtorrent/complete/[Anime-Koi] Tokyo Ravens - 01v2 [h264-720p][9E02D3C9].mkv
d.get_hash: 0CF0C7F75D18281AE7C65309F6B798CEB149BCB8
d.is_active:
d.get_down_total:
d.get_up_total:
d.get_size_bytes:

d.get_name: [Anime-Koi] Tokyo Ravens - 03 [h264-720p][C997AD9B].mkv
d.get_base_path: /data/rtorrent/complete/[Anime-Koi] Tokyo Ravens - 03 [h264-720p][C997AD9B].mkv
d.get_hash: 8CAA3ED5CB29999A6DA84739FDFF2D6B04489833
d.is_active:
d.get_down_total:
d.get_up_total:
d.get_size_bytes:

Multicall 可以在一个请求中获取所有内容。但同样在这里 - 不起作用。

print_r(request("d.multicall",array(
"main",
"d.get_name=",
"d.get_base_path=",
"d.get_up_total=",
"d.get_size_bytes=",
"d.get_down_total=",
"d.get_completed_chunks=",
"d.get_connection_current=",
"d.get_connection_leech=",
"d.get_connection_seed=",
"d.get_creation_date="
)));
Array
(
[0] => Array
(
[0] => [Anime-Koi] Tokyo Ravens - 01v2 [h264-720p][9E02D3C9].mkv
[1] => /data/rtorrent/complete/[Anime-Koi] Tokyo Ravens - 01v2 [h264-720p][9E02D3C9].mkv
[2] =>
[3] =>
[4] =>
[5] =>
[6] => seed
[7] =>
[8] =>
[9] =>
)

[1] => Array
(
[0] => [Anime-Koi] Tokyo Ravens - 03 [h264-720p][C997AD9B].mkv
[1] => /data/rtorrent/complete/[Anime-Koi] Tokyo Ravens - 03 [h264-720p][C997AD9B].mkv
[2] =>
[3] =>
[4] =>
[5] =>
[6] => seed
[7] =>
[8] =>
[9] =>
)
)

不过,全局请求工作正常。

print_r(request('view_list',null));
Array
(
[0] => main
[1] => default
[2] => name
[3] => active
[4] => started
[5] => stopped
[6] => complete
[7] => incomplete
[8] => hashing
[9] => seeding
[10] => leeching
)
print_r(request('system.listMethods',null));
Array
(
[0] => system.listMethods
[1] => system.methodExist
[2] => system.methodHelp
[...]
[959] => view_sort_new
[960] => xmlrpc_dialect
[961] => xmlrpc_size_limit
)

在请求函数中添加以下内容时,第一个 torrent 的 xml 请求的几个示例:

echo "request for \"$method\"\n".htmlentities($data)."\nresult: ";
request for "d.get_name"

<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>d.get_name</methodName>
<params>
<param>
<value>
<string>0CF0C7F75D18281AE7C65309F6B798CEB149BCB8</string>
</value>
</param>
</params>
</methodCall>

result: [Anime-Koi] Tokyo Ravens - 01v2 [h264-720p][9E02D3C9].mkv
request for "d.get_base_path"

<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>d.get_base_path</methodName>
<params>
<param>
<value>
<string>0CF0C7F75D18281AE7C65309F6B798CEB149BCB8</string>
</value>
</param>
</params>
</methodCall>

result: /data/rtorrent/complete/[Anime-Koi] Tokyo Ravens - 01v2 [h264-720p][9E02D3C9].mkv
request for "d.get_down_total"

<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>d.get_down_total</methodName>
<params>
<param>
<value>
<string>0CF0C7F75D18281AE7C65309F6B798CEB149BCB8</string>
</value>
</param>
</params>
</methodCall>

result:
request for "d.get_size_bytes"

<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>d.get_size_bytes</methodName>
<params>
<param>
<value>
<string>0CF0C7F75D18281AE7C65309F6B798CEB149BCB8</string>
</value>
</param>
</params>
</methodCall>

result:

我做错了什么,只有一些请求返回有用的东西?

最佳答案

这是 PHP-XMLRPC 中的错误。

但是你可以替换你的行:

$response = xmlrpc_decode(curl_exec($ch));

与:

$response = xmlrpc_decode(str_replace('i8>', 'i4>', curl_exec($ch)));

这应该按预期工作。

关于php - 来自 rtorrent 的空 xmlrpc 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22009054/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com