/** * Get informations about the logged account * * @return \stdClass Account informations; NULL if the user is not authenticated * @throws ForbiddenException User is not authenticated */ public function account() { if (!$this->is_authenticated()) { throw new ForbiddenException(); } $account = CURL::exec('api/account.php?out=json'); return json_decode($account); }
/** * Unrestrict a link * * @param string $link Link of the file * @param string $password Optionally tell the password to the file * @return \stdClass Unrestricted link * @throws \Exception */ public function unrestrict($link, $password = '') { if (!$this->is_authenticated()) { throw new ForbiddenException(); } $resp = CURL::exec('ajax/unrestrict.php?out=json&link=' . $link . '&password=' . $password); $resp = json_decode($resp); // Error handling if ($resp->error > 0) { throw new \Exception($resp->message); } return $resp; }
/** * Start torrent * * @param int $id Torrent ID * @throws \Exception */ private function start($id) { $curl_opts[CURLOPT_REFERER] = CURL::$API . 'torrents'; $curl_opts[CURLOPT_POST] = true; $curl_opts[CURLOPT_POSTFIELDS] = 'files_unwanted=&start_torrent=1'; $curl_opts[CURLOPT_HTTPHEADER] = array('Content-Type: application/x-www-form-urlencoded'); CURL::exec('ajax/torrent_files.php?id=' . $id, $curl_opts); }