PHP code example of demorfi / synox-web-api

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

    

demorfi / synox-web-api example snippets


$api = new \SynoxWebApi\Api('https://synox-web.domain/api/');

$search = $api->search();
$search->makeFilters()->addCategory('video')->addPackage('tpb'); // optional make filters
$profile = null; // optional profile name 
foreach ($search->create('Silent Hill', $profile)->run() as $item) {
    printf("Title: %s; Size: %s\n", $item->getTitle(), $item->getWeight());
    // download only this torrent file
    if (stripos($item->getTitle(), 'Silent Hill 2') !== false) {
        // $item->getFetchId(); fetched id for download
        file_put_contents('file.torrent', $item->fetch()->download());
        return;
    }
}

$fetched = $api->content()->fetch('tpb', 'fetch id');
//$fetched->downloadUrn(); only URN path to torrent file
file_put_contents('file.torrent', $fetched->download());

$api->packages()->changeState('tpb', true); // enable this package