Do RPC calls to transmission-daemon through php
-
- Posts: 10
- Joined: Wed Jun 30, 2010 10:56 pm
Re: Do RPC calls to transmission-daemon through php
Yep, new version is commited and available as a download. Great work brycec! I was really impressed with the results of your merge.
-
- Posts: 10
- Joined: Wed Jun 30, 2010 10:56 pm
Re: Do RPC calls to transmission-daemon through php
I suggested the class for the recources list, and there it is
Tnx again
http://www.transmissionbt.com/resources.php

http://www.transmissionbt.com/resources.php
Re: Do RPC calls to transmission-daemon through php
@johan.adriaans
I did not yet tried the merged version.
I am now building on johan.adriaans version.
After basic implementation is done I will try to use this code.
However, there is a major bug in your code.
This has been added
I spend alot of time to fix this bug.
If you create an array with values 0 in it (it does not matter if you use 0,2 or 0,0,2 , 1,3,0 ...) these are unset by your cleanRequestData function.
(resulting in 2 , 2 , 1,3).
Also if you unset entries in an array, json_encode does interprete all entries as 'key', 'value' pairs as all index numbers are not following (index++).
Example:
This results in
This is the wrong data type for transmission-daemon. Although it does return a success state, it does actually get executed. (I used "wanted-files" for setting the files to download)
After doing array_values:
If you do unset, make sure you use $goodordervalue = array_values($thearray).
This will re-index the array.
I did not yet tried the merged version.
I am now building on johan.adriaans version.
After basic implementation is done I will try to use this code.
However, there is a major bug in your code.
Code: Select all
235 protected function cleanRequestData ( $array )
236 {
237 if ( !is_array( $array ) || count( $array ) == 0 ) return null;
238 foreach ( $array as $index => $value ) {
239 print(json_encode($array));
240 if( is_array( $array[$index] ) ) $array[$index] = $this->cleanRequestData( $array[$index] ); // Recursion
241 if ( empty( $value ) && $value!=0) unset( $array[$index] );
242 }
243 return $array;
244 }
Code: Select all
&& $value!=0
If you create an array with values 0 in it (it does not matter if you use 0,2 or 0,0,2 , 1,3,0 ...) these are unset by your cleanRequestData function.
(resulting in 2 , 2 , 1,3).
Also if you unset entries in an array, json_encode does interprete all entries as 'key', 'value' pairs as all index numbers are not following (index++).
Example:
Code: Select all
$anarray = array(5,4,7,2);
unset($anarray[2]);
json_encode($anarray);
Code: Select all
{"0"=>5, "1"=>4, "3"=>2}
After doing array_values:
Code: Select all
[5,4,2]
This will re-index the array.
-
- Posts: 10
- Joined: Wed Jun 30, 2010 10:56 pm
Re: Do RPC calls to transmission-daemon through php
@deadeyes
Tnx for pointing this out and working out a fix! I will test it and implement it in the current version.
Tnx for pointing this out and working out a fix! I will test it and implement it in the current version.
Re: Do RPC calls to transmission-daemon through php
Hi johan.adriaans,
You have been able to reproduce this issue?
You have been able to reproduce this issue?