config = $config; } public function cfgReadChar($param) { if (!is_array($this->config)) return NULL; $pos = strpos($param,'.'); if ($pos!==false) { $section = trim(substr($param,0,$pos)); $key = trim(substr($param,$pos+1)); if (array_key_exists($section,$this->config)) { $config = $this->config[$section]; if (is_array($config) && array_key_exists($key,$config)) { return $config[$key]; } } } return NULL; } public function cfgReadLong($param) { return (int)$this->cfgReadChar($param); } public function savvy_api($in) { return $this->savvyext_api($in); } public function savvyext_api($in) { $postdata = json_encode($in); $ch = curl_init($this->cfgReadChar('savvyext.url')); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_VERBOSE, false); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'content-type: application/json', 'content-length: ' . strlen($postdata), 'server-token: ' . $this->cfgReadChar('savvyext.token') ]); curl_setopt($ch, CURLOPT_HEADER, false); // Do not show the response headers curl_setopt($ch, CURLOPT_USERPWD, base64_decode($this->cfgReadChar('savvyext.key'))); curl_setopt($ch, CURLOPT_TIMEOUT, 60); $res = curl_exec($ch); //echo "DEBUG: ".$res."=====\n"; curl_close($ch); return json_decode($res, true); } };