protected function request($url, $parameters = array(), $request = false)
        {
            $this->lastRequest = $url;
            $this->lastRequestData = $parameters;
            $this->responseHeaders = array();

            $curl = curl_init($url);

            $curlOptions = array(
                CURLOPT_SSL_VERIFYPEER => false,
                CURLOPT_REFERER        => $url,
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_HEADERFUNCTION => array($this, 'parseHeader'),
            );

            if (! empty($parameters) || ! empty($request)) {
                if (! empty($request)) {
                    $curlOptions[ CURLOPT_CUSTOMREQUEST ] = $request;
                    $parameters = http_build_query($parameters);
                } else {
                    $curlOptions[ CURLOPT_POST ] = true;
                }

                $curlOptions[ CURLOPT_POSTFIELDS ] = $parameters;
            }

            curl_setopt_array($curl, $curlOptions);

            $response = curl_exec($curl);
            $error    = curl_error($curl);

            $this->lastRequestInfo = curl_getinfo($curl);

            curl_close($curl);

            if (! empty($error)) {
                throw new \Exception($error);
            }

            return $this->parseResponse($response);
        }
protected function request($url, $parameters = array(), $request = false)
        {
            $this->lastRequest = $url;
            $this->lastRequestData = $parameters;
            $this->responseHeaders = array();

            $curl = curl_init($url);

            $curlOptions = array(
                CURLOPT_SSL_VERIFYPEER => false,
                CURLOPT_REFERER        => $url,
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_HEADERFUNCTION => array($this, 'parseHeader'),
            );

            if (! empty($parameters) || ! empty($request)) {
                if (! empty($request)) {
                    $curlOptions[ CURLOPT_CUSTOMREQUEST ] = $request;
                    $parameters = http_build_query($parameters);
                } else {
                    $curlOptions[ CURLOPT_POST ] = true;
                }

                $curlOptions[ CURLOPT_POSTFIELDS ] = $parameters;
            }

            curl_setopt_array($curl, $curlOptions);

            $response = curl_exec($curl);
            $error    = curl_error($curl);

            $this->lastRequestInfo = curl_getinfo($curl);

            curl_close($curl);

            if (! empty($error)) {
                throw new \Exception($error);
            }

            return $this->parseResponse($response);
        }
protected function request ( $ url , $ parameters = array ( ) , $ request = false ) { $ this -> lastRequest = $ url ; $ this -> lastRequestData = $ parameters ; $ this -> responseHeaders = array ( ) ; $ curl = curl_init ( $ url ) ; $ curlOptions = array ( CURLOPT_SSL_VERIFYPEER => false , CURLOPT_REFERER => $ url , CURLOPT_RETURNTRANSFER => true , CURLOPT_HEADERFUNCTION => array ( $ this , 'parseHeader' ) , ) ; if ( ! empty ( $ parameters ) || ! empty ( $ request ) ) { if ( ! empty ( $ request ) ) { $ curlOptions [ CURLOPT_CUSTOMREQUEST ] = $ request ; $ parameters = http_build_query ( $ parameters ) ; } else { $ curlOptions [ CURLOPT_POST ] = true ; } $ curlOptions [ CURLOPT_POSTFIELDS ] = $ parameters ; } curl_setopt_array ( $ curl , $ curlOptions ) ; $ response = curl_exec ( $ curl ) ; $ error = curl_error ( $ curl ) ; $ this -> lastRequestInfo = curl_getinfo ( $ curl ) ; curl_close ( $ curl ) ; if ( ! empty ( $ error ) ) { throw new \ Exception ( $ error ) ; } return $ this -> parseResponse ( $ response ) ; }
Makes HTTP Request to the API

@param string $url
@param array $parameters
@param bool|string $request the request method, default is POST

@return mixed
@throws \Exception
Makes HTTP Request to the API