public function request($url, $content = false, $customRequest = false)
    {

        $request_parts = explode('/', $url);
        $request = $request_parts[3];

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        if(strpos($url,'test')){
            curl_setopt($ch, CURLOPT_USERPWD,
                $this->username . ":" . $this->testPassword);
        }else{
            curl_setopt($ch, CURLOPT_USERPWD,
                $this->username . ":" . $this->password);
        }

        curl_setopt($ch, CURLOPT_HTTPHEADER,
            array("Content-Type:application/xml;charset=UTF-8"));

        if ($content && !$customRequest) {
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
        }

        if ($customRequest) {
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $customRequest);
        }

        $output = curl_exec($ch);

        $outputINFO = curl_getinfo($ch);

        $this->log([
            "httpcode" => $outputINFO['http_code'],
            "url" => $url,
            "endpoint" => $request,
            "output" => $output
        ]);

        if ($outputINFO['http_code'] >= 400 || curl_errno($ch)) {
            $this->log(curl_error($ch), "error");
            $this->log($output, "error");
        } else {
            $this->log(".datacite.".$request.".response:".$output);
        }

        curl_close($ch);
        return $output;
    }
public function request($url, $content = false, $customRequest = false)
    {

        $request_parts = explode('/', $url);
        $request = $request_parts[3];

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        if(strpos($url,'test')){
            curl_setopt($ch, CURLOPT_USERPWD,
                $this->username . ":" . $this->testPassword);
        }else{
            curl_setopt($ch, CURLOPT_USERPWD,
                $this->username . ":" . $this->password);
        }

        curl_setopt($ch, CURLOPT_HTTPHEADER,
            array("Content-Type:application/xml;charset=UTF-8"));

        if ($content && !$customRequest) {
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
        }

        if ($customRequest) {
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $customRequest);
        }

        $output = curl_exec($ch);

        $outputINFO = curl_getinfo($ch);

        $this->log([
            "httpcode" => $outputINFO['http_code'],
            "url" => $url,
            "endpoint" => $request,
            "output" => $output
        ]);

        if ($outputINFO['http_code'] >= 400 || curl_errno($ch)) {
            $this->log(curl_error($ch), "error");
            $this->log($output, "error");
        } else {
            $this->log(".datacite.".$request.".response:".$output);
        }

        curl_close($ch);
        return $output;
    }
public function request ( $ url , $ content = false , $ customRequest = false ) { $ request_parts = explode ( '/' , $ url ) ; $ request = $ request_parts [ 3 ] ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; if ( strpos ( $ url , 'test' ) ) { curl_setopt ( $ ch , CURLOPT_USERPWD , $ this -> username . ":" . $ this -> testPassword ) ; } else { curl_setopt ( $ ch , CURLOPT_USERPWD , $ this -> username . ":" . $ this -> password ) ; } curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( "Content-Type:application/xml;charset=UTF-8" ) ) ; if ( $ content && ! $ customRequest ) { curl_setopt ( $ ch , CURLOPT_POST , 1 ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ content ) ; } if ( $ customRequest ) { curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , $ customRequest ) ; } $ output = curl_exec ( $ ch ) ; $ outputINFO = curl_getinfo ( $ ch ) ; $ this -> log ( [ "httpcode" => $ outputINFO [ 'http_code' ] , "url" => $ url , "endpoint" => $ request , "output" => $ output ] ) ; if ( $ outputINFO [ 'http_code' ] >= 400 || curl_errno ( $ ch ) ) { $ this -> log ( curl_error ( $ ch ) , "error" ) ; $ this -> log ( $ output , "error" ) ; } else { $ this -> log ( ".datacite." . $ request . ".response:" . $ output ) ; } curl_close ( $ ch ) ; return $ output ; }
Do an actual request to the specified URL

@todo don't use curl, use guzzle
@param $url
@param bool $content
@param bool $customRequest
@return mixed
Do an actual request to the specified URL