diff --git a/lib/Transmission/Util/ResponseValidator.php b/lib/Transmission/Util/ResponseValidator.php index ee5a1b7..fcb98bc 100644 --- a/lib/Transmission/Util/ResponseValidator.php +++ b/lib/Transmission/Util/ResponseValidator.php @@ -59,7 +59,18 @@ public static function validateGetResponse(\stdClass $response) */ public static function validateAddResponse(\stdClass $response) { - $fields = array('torrent-added', 'torrent-duplicate'); + // fix for issue #35 + if ($response -> result == 'success' && + isset ($response->arguments -> {torrent-added}) && + count($response->arguments -> {torrent-added})) + { + return $response->arguments -> {torrent-added}; + } + if ($response -> result == 'duplicate torrent') + return $response -> result; + + + /*$fields = array('torrent-added', 'torrent-duplicate'); foreach ($fields as $field) { if (isset($response->arguments) && @@ -67,7 +78,7 @@ public static function validateAddResponse(\stdClass $response) count($response->arguments->$field)) { return $response->arguments->$field; } - } + }*/ throw new \RuntimeException('Invalid response received from Transmission'); }