PHP code example of happydemon / transmission

1. Go to this page and download the library: Download happydemon/transmission 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/ */

    

happydemon / transmission example snippets


 $transmission = new \HappyDemon\Transmission\Transmission();
 

 var_dump($transmission->torrents()->get());
 

$transmission->torrents()->get();

// Get the torrent with id 1
$transmission->torrents()->get(1);


// Get a few torrents
$transmission->torrents()->get([1,6,12]);

$torrent = $transmission->torrents()->addFromUrl($urlToTorrent);
$torrent = $transmission->torrents()->addFile($filePath);
$torrent = $transmission->torrents()->addFromBase64($fileBlob);

$torrent = $transmission->torrents()->addFromUrl($urlToTorrent, ['uploadLimit' => 512]);

$torrents = $transmission->torrents()->defaults(['uploadLimit' => 512]);

$torrent = $torrents->addFromUrl($urlToTorrent);

$torrent->start();

$torrent->stop();

$torrent->verify();

$torrent->announce();

$torrent->remove();

$torrent->move();

$torrent->settings($properties);

// remove the download limit
$torrent->setDownloadLimited(false);

// set the bandwidth priority
$torrent->setBandwidthPriority(1);

// set the download limit (in K/s)
$torrent->setDownloadLimit(1024*3);

// Mark files as wanted
// Use an empty array for all files, use an array of ids to be more selective [0,2]
// In this case we only want to download the second file
$torrent->setFilesWanted([1]);

// Mark files as unwanted
// Use an empty array for all files, use an array of ids to be more selective [0,2]
// In this case we don't want to download the first file
$torrent->setFilesUnwanted([0]);

// true if session upload limits are honored
$torrent->setHonorsSessionLimits(true);

// Set a new directory for the torrent's contents
$torrent->setLocation('c:/downloads');

// Set the peer limit (max amount of peer)
$torrent->setPeerLimit(40);

// Set the priority for files to high
// Use en empty array to update priority for all files
// or use the file ids [0,2]
$torrent->setPriorityHigh([]);

// Set the priority for files to low
// Use en empty array to update priority for all files
// or use the file ids [0,2]
$torrent->setPriorityLow(false);

// Set the priority for files to normall
// Use en empty array to update priority for all files
// or use the file ids [0,2]
$torrent->setPriorityNormal(false);

// Set the seed ratio limit
$torrent->setSeedRatioLimit(1.2);

// Set the seed ratio mode
// 0 = global, 1 = see seedRatioLimit, 2 = unlimitted
$torrent->setSeedRatioMode(1);

// Change the upload limit (in K/s)
$torrent->setUploadLimit(512);

// Should the torrent's upload be limitted?
$torrent->setUploadLimited(false);

$torrent->status();

$torrent->activityDate();

$torrent->addedDate();

$torrent->doneDate();

$torrent->percentDone();