ktorfs/transmission-rpc

100% 面向对象的 Transmission RPC 客户端 PHP。此库为您提供了从 Transmission 守护进程可用的所有请求和响应的代码自动完成。

1.0.2 2015-04-24 12:25 UTC

This package is auto-updated.

Last update: 2024-09-07 02:09:12 UTC


README

Transmission 的 100% 面向对象 RPC 客户端。此库为您提供了从 Transmission 守护进程可用的所有请求和响应的代码自动完成。

计划始终与 Transmission RPC 规范 保持同步。如果您注意到我在规范方面落后了,请通过打开一个新的 问题 来通知我。

安装

安装通过 composer 完成。

使用示例

use \Transmission\Transmission;
use \Transmission\Requests;
use \Transmission\Responses;

try {
    $tr = new Transmission();
    $request = new Requests\TorrentGet();
    $request->fields = array(Requests\TorrentGet::eta, Requests\TorrentGet::name, Requests\TorrentGet::percentDone);
    #$request->includeAll();
    $response = $tr->torrentGet($request);
    foreach($response->torrents as $torrent) {
        printf('%s: %d%% done, %d seconds left<br>', $torrent->name, $torrent->percentDone * 100, $torrent->eta);
    }
} catch (Exception $e) {
    printf('Error %d - %s', $e->getCode(), $e->getMessage());
}