debug = debug_backtrace(); if ($this->getArgs(func_get_args())) { $this->params = array( "document" => $cpf ); $this->setMetodo('parada/api'); return $this->setParams(); } else { return false; } } ######################################################################## ## FUNCOES DO SISTEMA ## ######################################################################## function __construct($url_api, $log = false, $selfSigned = true) { $this->url_api = $url_api; $this->selfSigned = $selfSigned; $this->setLog($log); $this->integracaoReg(); $this->log->info("Iniciando integracao com AtekyApi", debug_backtrace()); } private function setMetodo($metodo) { $this->metodo = $metodo; } /** * Escreve a query para ser passada para o curl * * @param string $query */ private function setQuery($query) { return $this->query .= $query; } private function getQuery() { $query = $this->query; unset($this->query); return $query; } private function strCurl() { $this->curl = "curl -X POST"; $this->curl .= sprintf(" -H 'Content-Type: application/json' -d "); $this->curl .= "'".$this->getQuery()."'"; $this->curl .= " {$this->url_api}{$this->metodo}"; var_dump($this->curl); $this->log->debug("Curl: {$this->curl}", debug_backtrace()); } private function setParams() { if ($this->params) { $this->setQuery(json_encode($this->params)); } unset($this->params); $this->strCurl(); $result = $this->exec(); $ret = json_decode($result, true); return $ret; } function exec() { $exec = shell_exec($this->curl); return $this->response($exec); } private function response($data) { $this->log->debug("Reponse API: " . print_r(json_decode($data, true), true), $this->debug); if ($data) { return $data; } else { return false; } } }