this function is working:
Code: Select all
$rpc = new TransmissionRPC();
$result = $rpc->add_file( 'test.torrent', '/torrentsdata' );
$id = $result->arguments->torrent_added->id;
public function add_file( $torrent_location, $save_path = '', $extra_options = array() )
{
$extra_options['download-dir'] = $save_path;
$extra_options['filename'] = $torrent_location;
return $this->request( "torrent-add", $extra_options );
}
Code: Select all
$rpc->return_as_array = true;
$rpc->debug = true;
$result = $rpc->get( '12', array("id", "name", "status", "doneDate", "haveValid", "totalSize", "uploadRatio", "isFinished","percentDone","recheckProgress") );
print_r($result);
$rpc->return_as_array = false;
public function get ( $ids = array(), $fields = array() )
{
if ( !is_array( $ids ) ) $ids = array( $ids ); // Convert $ids to an array if only a single id was passed
if ( count( $fields ) == 0 ) $fields = array( "id", "name", "status", "doneDate", "haveValid", "totalSize", "uploadRatio", "isFinished","percentDone","recheckProgress"); // Defaults
$request = array(
"fields" => $fields,
"ids" => $ids
);
return $this->request( "torrent-get", $request );
}
Code: Select all
TRANSMISSIONRPC_DEBUG:: request( method=torrent-get, ...):: 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: RoVC5z2AgG7f0Ka5NgXenV4Uytusfd2EtgxRaJfJKCGfjcO5 [content] => {"method":"torrent-get","arguments":{"fields":["id","name","status","doneDate","haveValid","totalSize","uploadRatio","isFinished","percentDone","recheckProgress"],"ids":["25"]}} ) ) TRANSMISSIONRPC_DEBUG:: request( method=torrent-get, ...):: POST Result: {"arguments":{"torrents":[]},"result":"success"} TRANSMISSIONRPC_DEBUG:: request( method=torrent-get, ...):: 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 )
thanks