Transmission RPC PHP Library

ATTENTION!

This project has merged with Johan Adriaans'. Please visit http://code.google.com/p/php-transmission-class/
(This page left up for archival and historical purposes.)


Introduction

I wrote this library as an easy means to interface a PHP script I was working on with Transmission Bittorrent client using Transmission's RPC method. The library is still relatively skeleton right now, but it should support all of Transmission's RPC methods as of Transmission 2.01 (RPC version 9). 
Disclaimer: It has not been thoroughly tested. Is that clear? Not fully tested. It works for my project, and when I'm done with the project I'll focus on the library. For now though, it's a solid stepping-stone.

Example:

Usage is very simple. The following will return the same data the "transmission-remote -l" retrieves from the RPC.
<?php
require_once('transmissionRPC.php');
$transmissionRPC = new TransmissionRPC('http://HOSTNAME:9091/transmission/rpc');
var_dump($transmissionRPC->torrent_get(
		array(),	// id's
		array(		// Fields
				"error",
				"errorString",
				"eta",
				"id",
				"leftUntilDone",
				"name",
				"peersGettingFromUs",
				"peersSendingToUs",
				"rateDownload",
				"rateUpload",
				"sizeWhenDone",
				"status",
				"uploadRatio"
			)
		)
	);
?>

Known Caveats/Issues/Shortcomings:

Doesn't parse the "result" field - that's up to you.
Doesn't do any protocol version checking.
Debugging could be much cleaner.
Could do some input-checking and validation.
Could add some convenience methods, such as list_torrents.
Does NOT support authentication yet. (Ensure that your Transmission server is secured, IP-based masking, firewall, etc)
Should verify all text is UTF-8 encoded.
Error reporting could use improvement.

ChangeLog:

Version 0.1 - Initial release. Still very rough.

Credits:

Based off JSON-RPC (http://jsonrpcphp.org/) client class.
The fine developers of Transmission Bittorrent client - my personal favourite, obviously. (http://transmissionbt.com/)

License:

This code is licensed under the GPLv2.
ċ
transmissionRPC-0.1.tar.gz
(12k)
Bryce Chidester,
Jun 28, 2010, 12:38 AM
Comments