我会使用这个类,它允许将传输软件与 php 一起使用,但我不能单独使用这些动作!
<?php
require_once( dirname( __FILE__ ) . '/TransmissionRPC.class.php' );
$test_torrent = "http://www.slackware.com/torrents/slackware64-13.1-install-dvd.torrent";
$rpc = new TransmissionRPC();
$rpc->sstats( );
if (isset($_GET['add']))
{
try
{
$result = $rpc->add( $test_torrent, '/tmp' );
$id = $result->arguments->torrent_added->id;
print "ADD TORRENT TEST... [{$result->result}] (id=$id)\n";
sleep( 2 );
$rpc->stop( $id );
} catch (Exception $e) {
die('[ERROR] ' . $e->getMessage() . PHP_EOL);
}
}
if (isset($_GET['start']))
{
try
{
$rpc->start( $_GET['start'] );
} catch (Exception $e) {
die('[ERROR] ' . $e->getMessage() . PHP_EOL);
}
}
添加种子运行后的第一个动作(停止种子)但我无法重新启动....
为@aergistal 和@Miguel 编辑:
当我打电话时,test2.php?add
我得到了这个结果
,所以,我打电话,我得到了这个结果
test2.php?start=1
TRANSMISSIONRPC_DEBUG:: request( method=torrent-start, ...):: Stream context created with options:
Array
(
[http] => Array
(
[user_agent] => TransmissionRPC for PHP/0.3
[ignore_errors] => 1
[method] => POST
[header] => Content-type: application/json
X-Transmission-Session-Id: 4C3KBYhu79SVvFcXrrG4RmpFLZaGu54RSLHT0hFqeVEmAmlV
[content] => {"method":"torrent-start","arguments":{"ids":["1"]}}
)
)
TRANSMISSIONRPC_DEBUG:: request( method=torrent-start, ...):: POST Result:
{"arguments":{},"result":"success"}
TRANSMISSIONRPC_DEBUG:: request( method=torrent-start, ...):: Stream meta info:
Array
(
[wrapper_data] => Array
(
[0] => HTTP/1.0 200 OK
[1] => Server: Transmission
[2] => Content-Type: application/json; charset=UTF-8
)
[wrapper_type] => http
[stream_type] => tcp_socket/ssl
[mode] => r
[unread_bytes] => 0
[seekable] =>
[uri] => http://localhost:9091/transmission/rpc
[timed_out] =>
[blocked] => 1
[eof] => 1
)