PHP code example of kimdongwan121 / transmission-php
1. Go to this page and download the library: Download kimdongwan121/transmission-php 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/ */
kimdongwan121 / transmission-php example snippets
use Transmission\Transmission;
$transmission = new Transmission();
// Getting all the torrents currently in the download queue
$torrents = $transmission->all();
// Getting a specific torrent from the download queue
$torrent = $transmission->get(1);
// (you can also get a torrent by the hash of the torrent)
$torrent = $transmission->get(/* torrent hash */);
// Adding a torrent to the download queue
$torrent = $transmission->add(/* path to torrent */);
// Removing a torrent from the download queue
$torrent = $transmission->get(1);
$transmission->remove($torrent);
// Or if you want to delete all local data too
$transmission->remove($torrent, true);
// You can also get the Trackers that the torrent currently uses
// These are instances of the Transmission\Model\Tracker class
$trackers = $torrent->getTrackers();
// You can also get the Trackers statistics and info that the torrent currently has
// These are instances of the Transmission\Model\trackerStats class
$trackerStats = $torrent->getTrackerStats();
// To get the start date/time of the torrent in UNIX Timestamp format
$startTime = $torrent -> getStartDate();
// To get the number of peers connected
$connectedPeers = $torrent -> getPeersConnected();
// Getting the files downloaded by the torrent are available too
// These are instances of Transmission\Model\File
$files = $torrent->getFiles();
// You can start, stop, verify the torrent and ask the tracker for
// more peers to connect to
$transmission->stop($torrent);
$transmission->start($torrent);
$transmission->start($torrent, true); // Pass true if you want to start the torrent immediatly
$transmission->verify($torrent);
$transmission->reannounce($torrent);
use Transmission\Transmission;
$transmission = new Transmission('example.com', 33);
$torrents = $transmission->all();
$torrent = $transmission->get(1);
$torrent = $transmission->add(/* path to torrent */);
// When you already have a torrent, you don't have to pass the client again
$torrent->delete();
use Transmission\Client;
use Transmission\Transmission;
$client = new Client();
$client->authenticate('username', 'password');
$transmission = new Transmission();
$transmission->setClient($client);
use Transmission\Transmission;
$transmission = new Transmission();
$session = $transmission->getSession();
$session->setDownloadDir('/home/foo/downloads/complete');
$session->setIncompleteDir('/home/foo/downloads/incomplete');
$session->setIncompleteDirEnabled(true);
$session->save();