/** * Send data to webservice over POST method * * @param void * @return http json response * @throws GlobKurierExceptions */ public function sendData() { $fields_string = null; foreach ($this->getData() as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } if (GlobKurierTools::isCurl()) { $c = curl_init(); curl_setopt($c, CURLOPT_URL, GlobKurierConfig::PS_GK_URL_ADDONS . '?' . $fields_string); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); $page = curl_exec($c); curl_close($c); return $page; } else { die('ERROR: You need to enable curl php extension to use GlobKurier module.'); } }
/** * Send data to webservice over POST method * * @param void * @return http json response */ public function sendData() { $headers = array('Authorization: Basic ' . base64_encode(GlobKurierConfig::PS_GK_WS_LOGIN . ':' . GlobKurierConfig::PS_GK_WS_PASSWD)); if (GlobKurierTools::isCurl()) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, GlobKurierConfig::PS_GK_URL_ORDER); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'DATA=' . $this->getXmlData()); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $output = curl_exec($ch); curl_close($ch); return $output; } else { die('ERROR: You need to enable curl php extension to use GlobKurier module.'); } }