protected function _makeCall($function, $params = null, $method = 'GET') {
        if (isset($params['count']) && $params['count'] < 1) {
            throw new InvalidParameterException('InstagramClient: you are trying to query 0 records!');
        }

        // if the call needs an authenticated user
        if (true === isset($this->_accesstoken)) {
            $authMethod = '?access_token=' . $this->getAccessToken();
        } else {
            throw new AuthException("Error: _makeCall() | This method requires an valid users access token.");
        }

        if (isset($params) && is_array($params)) {
            $paramString = '&' . http_build_query($params);
        } else {
            $paramString = null;
        }

        $apiCall = self::API_URL . $function . $authMethod . (('GET' === $method) ? $paramString : null);

        // we want JSON
        $headerData = array('Accept: application/json');

        if ($this->_enforceSignedRequests) {
            $apiCall .= (strstr($apiCall, '?') ? '&' : '?') . 'sig=' . $this->_signHeader($function, $authMethod, $params);
        }

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $apiCall);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headerData);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        if ('POST' === $method) {
            curl_setopt($ch, CURLOPT_POST, count($params));
            curl_setopt($ch, CURLOPT_POSTFIELDS, ltrim($paramString, '&'));
        } else if ('DELETE' === $method) {
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
        }

        $jsonData = curl_exec($ch);

        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        if(403 === $httpcode) {
            $error = json_decode($jsonData, true);
            throw new CurlException('_makeCall() - ' . $error['error_type'] . ' error: ' . $error['error_message']);
        }

        if (false === $jsonData) {
            throw new CurlException('_makeCall() - cURL error: ' . curl_error($ch));
        }
        curl_close($ch);

        return json_decode($jsonData);
    }
protected function _makeCall($function, $params = null, $method = 'GET') {
        if (isset($params['count']) && $params['count'] < 1) {
            throw new InvalidParameterException('InstagramClient: you are trying to query 0 records!');
        }

        // if the call needs an authenticated user
        if (true === isset($this->_accesstoken)) {
            $authMethod = '?access_token=' . $this->getAccessToken();
        } else {
            throw new AuthException("Error: _makeCall() | This method requires an valid users access token.");
        }

        if (isset($params) && is_array($params)) {
            $paramString = '&' . http_build_query($params);
        } else {
            $paramString = null;
        }

        $apiCall = self::API_URL . $function . $authMethod . (('GET' === $method) ? $paramString : null);

        // we want JSON
        $headerData = array('Accept: application/json');

        if ($this->_enforceSignedRequests) {
            $apiCall .= (strstr($apiCall, '?') ? '&' : '?') . 'sig=' . $this->_signHeader($function, $authMethod, $params);
        }

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $apiCall);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headerData);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        if ('POST' === $method) {
            curl_setopt($ch, CURLOPT_POST, count($params));
            curl_setopt($ch, CURLOPT_POSTFIELDS, ltrim($paramString, '&'));
        } else if ('DELETE' === $method) {
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
        }

        $jsonData = curl_exec($ch);

        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        if(403 === $httpcode) {
            $error = json_decode($jsonData, true);
            throw new CurlException('_makeCall() - ' . $error['error_type'] . ' error: ' . $error['error_message']);
        }

        if (false === $jsonData) {
            throw new CurlException('_makeCall() - cURL error: ' . curl_error($ch));
        }
        curl_close($ch);

        return json_decode($jsonData);
    }
protected function _makeCall ( $ function , $ params = null , $ method = 'GET' ) { if ( isset ( $ params [ 'count' ] ) && $ params [ 'count' ] < 1 ) { throw new InvalidParameterException ( 'InstagramClient: you are trying to query 0 records!' ) ; } // if the call needs an authenticated user if ( true === isset ( $ this -> _accesstoken ) ) { $ authMethod = '?access_token=' . $ this -> getAccessToken ( ) ; } else { throw new AuthException ( "Error: _makeCall() | This method requires an valid users access token." ) ; } if ( isset ( $ params ) && is_array ( $ params ) ) { $ paramString = '&' . http_build_query ( $ params ) ; } else { $ paramString = null ; } $ apiCall = self :: API_URL . $ function . $ authMethod . ( ( 'GET' === $ method ) ? $ paramString : null ) ; // we want JSON $ headerData = array ( 'Accept: application/json' ) ; if ( $ this -> _enforceSignedRequests ) { $ apiCall .= ( strstr ( $ apiCall , '?' ) ? '&' : '?' ) . 'sig=' . $ this -> _signHeader ( $ function , $ authMethod , $ params ) ; } $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ apiCall ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headerData ) ; curl_setopt ( $ ch , CURLOPT_CONNECTTIMEOUT , 5 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , false ) ; if ( 'POST' === $ method ) { curl_setopt ( $ ch , CURLOPT_POST , count ( $ params ) ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , ltrim ( $ paramString , '&' ) ) ; } else if ( 'DELETE' === $ method ) { curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , 'DELETE' ) ; } $ jsonData = curl_exec ( $ ch ) ; $ httpcode = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; if ( 403 === $ httpcode ) { $ error = json_decode ( $ jsonData , true ) ; throw new CurlException ( '_makeCall() - ' . $ error [ 'error_type' ] . ' error: ' . $ error [ 'error_message' ] ) ; } if ( false === $ jsonData ) { throw new CurlException ( '_makeCall() - cURL error: ' . curl_error ( $ ch ) ) ; } curl_close ( $ ch ) ; return json_decode ( $ jsonData ) ; }
The call operator

@param string $function              API resource path
@param array [optional] $params      Additional request parameters
@param string [optional] $method     Request type GET|POST
@return mixed
The call operator