public function main() { if (\helper\StringHelper::isNull($this->callback)) { throw new \Exception('Callback is required'); } if (!isset($_POST['exec'])) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, array('exec' => 'true')); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $result = trim(curl_exec($curl)); echo $result; curl_close($curl); } else { \core\Logger::info('start'); \helper\ReflectionHelper::getMethodResultFromInstance($this, $this->callback); \core\Logger::info('stop'); } }
public function Send($params = []) { $s = $this->initCurl($params["url"]); logger::info("Connect to: " . $params["url"]); $this->response = curl_exec($s); logger::info("Response: " . $this->response); if (curl_errno($s) == CURLE_COULDNT_CONNECT) { throw new \Exception('Couldnt connect.'); } $status = curl_getinfo($s, CURLINFO_HTTP_CODE); $last_url = parse_url(curl_getinfo($s, CURLINFO_EFFECTIVE_URL)); $err = curl_error($s); curl_close($s); }