1. Go to this page and download the library: Download martial/transmission-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
martial / transmission-api example snippets
// Load composer autoloader
$httpClient = new GuzzleHttp\Client(['base_uri' => 'http://transmission-server:9091/transmission/rpc']);
$api = new \Martial\Transmission\API\RpcClient($httpClient, 'rpc-username', 'rpc-password');
$logger = new \Monolog\Logger('transmission');
$logger->pushHandler(new \Monolog\Handler\StreamHandler('php://stdout'));
$api = new \Martial\Transmission\API\RpcClient($httpClient, 'rpc-username', 'rpc-password', $logger);
$sessionId = '';
try {
$api->sessionGet($sessionId);
} catch (\Martial\Transmission\API\CSRFException $e) {
// The session has been reinitialized. Fetch the new session ID with the method getSessionId().
$sessionId = $e->getSessionId();
} catch (\Martial\Transmission\API\TransmissionException $e) {
// The API returned an error, retrieve the reason with the method getResult().
die('API error: ' . $e->getResult());
}
try {
$api->torrentAdd($sessionId, [
\Martial\Transmission\API\Argument\Torrent\Add::FILENAME => '/path/to/the/torrent/file.torrent'
]);
} catch (\Martial\Transmission\API\DuplicateTorrentException $e) {
// This torrent is already in your download queue.
} catch (\Martial\Transmission\API\MissingArgumentException $e) {
// Some
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.