/** * @param $url * @param $headers * @param $method * @param $postData * @return bool|mixed */ private static function execute_curl($url, $headers, $method, $postData) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_URL, $url); if (!empty($postData)) { curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); } $server_output = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); $response = false; if ($info['http_code'] == 200 || $info['http_code'] == 201) { $response = true; } $settings = Settings::getInstance(); if ($settings->isDebug()) { $debugger = Debugger::getInstance(); $debugger->recordRequest($url, $headers, $method, $postData, $response, $server_output); $debugger->recordCurlInfo($info); } return array('response' => $response, 'output' => json_decode($server_output)); }
public function testRecordCurlInfo() { $this->debugger->recordCurlInfo('test_curl'); $this->assertEquals('test_curl', $this->debugger->getCurlInfo()); }