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);
}
}
torrent 実行中の追加後の最初のアクション (torrent を停止する) が、再起動できません ....
@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
)