Requests::get PHP Method

get() public method

public get ( $id )
    public function get($id)
    {
        $sth = $this->db->prepare('SELECT ' . implode(',', User::getDefaultFields()) . ', requests.id AS requestId, requests.request, requests.added, requests.filled, requests.p2p, requests.ersatt, requests.comment, requests.comments, requests.season, requests.imdbid, requests.typ, requests.slug, (SELECT COUNT(*) FROM reqvotes WHERE reqid = requests.id) AS votes, (SELECT SUM(krydda) FROM reqvotes WHERE reqid = requests.id) AS krydda FROM requests LEFT JOIN users ON requests.userid = users.id WHERE requests.id = ?');
        $sth->bindParam(1, $id, PDO::PARAM_INT);
        $sth->execute();
        $row = $sth->fetch(PDO::FETCH_ASSOC);
        if (!$row) {
            throw new Exception(L::get("REQUEST_NOT_FOUND"), 404);
        }
        $arr = array();
        $arr["id"] = $row["requestId"];
        $arr["added"] = $row["added"];
        $arr["filled"] = $row["filled"];
        $arr["request"] = $row["request"];
        $arr["p2p"] = $row["p2p"];
        $arr["comment"] = $row["comment"];
        $arr["comments"] = $row["comments"];
        $arr["ersatt"] = $row["ersatt"];
        $arr["season"] = $row["season"];
        $arr["slug"] = $row["slug"];
        $arr["imdbid"] = $row["imdbid"];
        $arr["type"] = $row["typ"];
        $arr["reward"] = $row["krydda"] += $this->getVoteTimeReward(strtotime($row["added"]));
        $arr["votes"] = $row["votes"];
        $arr["user"] = $this->user->generateUserObject($row);
        return $arr;
    }

Usage Example

 /**
  * post a GET request.
  */
 protected function get($method, $params = array(), $headers = array(), $options = array())
 {
     # construct the query URL.
     $url = self::HOST_API_URL . $method;
     $auth_head = $this->get_auth_header($this->access_key, $this->secret_key);
     if (!$headers) {
         $headers = array();
     }
     if (!$options) {
         $options = array();
     }
     // set timeout
     $options['timeout'] = 10 * 60;
     $headers['Authorization'] = $auth_head;
     // build query url.
     $url = $this->build_http_parameters($url, $params);
     // echo "$url";
     $response = Requests::get($url, $headers, $params, $options);
     // echo $response->body;
     # Handle any HTTP errors.
     if ($response->status_code != 200) {
         throw new ViSearchException("HTTP failure, status code {$response->status_code}");
     }
     # get the response as an object.
     $response_json = json_decode($response->body);
     return $response_json;
 }
All Usage Examples Of Requests::get