src/MVC/REST/REST.php
protected function exec($method, $uri, $data, $content_type)
    {
        $connect = $this->getConnect($uri, $method, $content_type);
        if ($data) {
            $this->setData($connect, $data, $content_type);
        }

        $api_result = curl_exec($connect);
        $api_http_code = curl_getinfo($connect, CURLINFO_HTTP_CODE);
        $api_http_time = curl_getinfo($connect, CURLINFO_TOTAL_TIME);

        $response = array(
            "status" => $api_http_code,
            "total_time" => $api_http_time,
        );

        if ($content_type == "application/json") {
            $response["response"] = json_decode($api_result, true);
        } elseif ($content_type == "text/html") {
            $response["response"] = $api_result;
        }

        if ($response['status'] >= 400) {
            throw new Exception($response['response'], $response['status']);
        }

        curl_close($connect);

        return $response;
    }
protected function exec($method, $uri, $data, $content_type)
    {
        $connect = $this->getConnect($uri, $method, $content_type);
        if ($data) {
            $this->setData($connect, $data, $content_type);
        }

        $api_result = curl_exec($connect);
        $api_http_code = curl_getinfo($connect, CURLINFO_HTTP_CODE);
        $api_http_time = curl_getinfo($connect, CURLINFO_TOTAL_TIME);

        $response = array(
            "status" => $api_http_code,
            "total_time" => $api_http_time,
        );

        if ($content_type == "application/json") {
            $response["response"] = json_decode($api_result, true);
        } elseif ($content_type == "text/html") {
            $response["response"] = $api_result;
        }

        if ($response['status'] >= 400) {
            throw new Exception($response['response'], $response['status']);
        }

        curl_close($connect);

        return $response;
    }
protected function exec ( $ method , $ uri , $ data , $ content_type ) { $ connect = $ this -> getConnect ( $ uri , $ method , $ content_type ) ; if ( $ data ) { $ this -> setData ( $ connect , $ data , $ content_type ) ; } $ api_result = curl_exec ( $ connect ) ; $ api_http_code = curl_getinfo ( $ connect , CURLINFO_HTTP_CODE ) ; $ api_http_time = curl_getinfo ( $ connect , CURLINFO_TOTAL_TIME ) ; $ response = array ( "status" => $ api_http_code , "total_time" => $ api_http_time , ) ; if ( $ content_type == "application/json" ) { $ response [ "response" ] = json_decode ( $ api_result , true ) ; } elseif ( $ content_type == "text/html" ) { $ response [ "response" ] = $ api_result ; } if ( $ response [ 'status' ] >= 400 ) { throw new Exception ( $ response [ 'response' ] , $ response [ 'status' ] ) ; } curl_close ( $ connect ) ; return $ response ; }
Executes the request
@access protected
@param string $method
@param string $uri
@param type $data
@param string $content_type
@return array
@throws \Exception
Executes the request