src/VPS/MailChimp.php
private function curlRequest($url, $httpVerb, array $data = array(), $curlTimeout = 15)
    {
        if (function_exists('curl_init') && function_exists('curl_setopt')) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
            curl_setopt($ch, CURLOPT_USERAGENT, 'VPS/MC-API:3.0');
            curl_setopt($ch, CURLOPT_TIMEOUT, $curlTimeout);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_USERPWD, "user:".$this->apiKey);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpVerb);
            
            //Submit data
            if (!empty($data)) {
                $jsonData = json_encode($data);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
            }
            
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $result = curl_exec($ch);
            curl_close($ch);
            
            return $result ? json_decode($result, true) : false;
        }

        throw new \Exception('curl extension is missing!');
    }
private function curlRequest($url, $httpVerb, array $data = array(), $curlTimeout = 15)
    {
        if (function_exists('curl_init') && function_exists('curl_setopt')) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
            curl_setopt($ch, CURLOPT_USERAGENT, 'VPS/MC-API:3.0');
            curl_setopt($ch, CURLOPT_TIMEOUT, $curlTimeout);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_USERPWD, "user:".$this->apiKey);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpVerb);
            
            //Submit data
            if (!empty($data)) {
                $jsonData = json_encode($data);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
            }
            
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $result = curl_exec($ch);
            curl_close($ch);
            
            return $result ? json_decode($result, true) : false;
        }

        throw new \Exception('curl extension is missing!');
    }
private function curlRequest ( $ url , $ httpVerb , array $ data = array ( ) , $ curlTimeout = 15 ) { if ( function_exists ( 'curl_init' ) && function_exists ( 'curl_setopt' ) ) { $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( 'Content-Type: application/json' ) ) ; curl_setopt ( $ ch , CURLOPT_USERAGENT , 'VPS/MC-API:3.0' ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT , $ curlTimeout ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , false ) ; curl_setopt ( $ ch , CURLOPT_USERPWD , "user:" . $ this -> apiKey ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , $ httpVerb ) ; //Submit data if ( ! empty ( $ data ) ) { $ jsonData = json_encode ( $ data ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ jsonData ) ; } curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; $ result = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; return $ result ? json_decode ( $ result , true ) : false ; } throw new \ Exception ( 'curl extension is missing!' ) ; }
Request using curl extension
@param string $url
@param string $httpVerb
@param array $data - Optional
@return array
Request using curl extension