2017 © Pedro Peláez
 

library transmission-api

A PHP client for the Transmission RPC API.

image

martial/transmission-api

A PHP client for the Transmission RPC API.

  • Thursday, February 1, 2018
  • by MartialGeek
  • Repository
  • 2 Watchers
  • 3 Stars
  • 676 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 0 % Grown

The README.md

PHP client for the Debian Transmission RPC API

Build Status, (*1)

Purpose

I wrote this client because of a lack of features with other PHP clients. This implementation is full, tested with PHPUnit and as close as possible from the original RPC interface., (*2)

Installation

With composer:, (*3)

composer require 'martial/transmission-api:~2.0'

Usage

Instantiation

// 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');

Show me what you're doing

You may want to use a logger:, (*4)

$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);

Session ID

You must provide a session ID as first parameter of all API methods. This ID can be retrieved by calling any of these methods with an invalid session ID, and by catching the \Martial\Transmission\API\CSRFException:, (*5)

$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());
}

Method usage example

Then, just read the documentation of the interface \Martial\Transmission\API\TransmissionAPI. Each method is documented:, (*6)

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 required arguments are missing.
} catch (\Martial\Transmission\API\CSRFException $e) {
    // The session has been reinitialized. Fetch the new session ID with the method getSessionId().
} catch (\Martial\Transmission\API\TransmissionException $e) {
    // The API returned an error, retrieve the reason with the method getResult().
    die('API error: ' . $e->getResult());
}

The Versions

01/02 2018

dev-master

9999999-dev

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2 AGPL-3.0-or-later

The Requires

 

The Development Requires

by Martial Saunois

23/05 2017

2.0.1

2.0.1.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois

29/03 2016

2.0.0

2.0.0.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois

11/03 2016

1.1.6

1.1.6.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois

08/03 2016

1.1.5

1.1.5.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois

20/01 2016

1.1.4

1.1.4.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois

19/01 2016

1.1.3

1.1.3.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois

18/01 2016

1.1.2

1.1.2.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois

18/01 2016

1.1.1

1.1.1.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois

16/01 2016

1.1.0

1.1.0.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois

13/01 2016

1.0.3

1.0.3.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois

08/01 2016

1.0.2

1.0.2.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois

08/01 2016

1.0.1

1.0.1.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois

07/01 2016

1.0.0

1.0.0.0

A PHP client for the Transmission RPC API.

  Sources   Download

GPL-v2

The Requires

 

The Development Requires

by Martial Saunois