function send_curl_request($verb, $url, $payload = '') { $logger = \APS\LoggerRegistry::get(); $application = \APS\Request::getController()->getResources("implementing(http://myweatherdemo.com/suwizardbasic/application/1.0)"); $token = $application[0]->provider_token; $headers = array('Content-type: application/json', 'x-provider-token: ' . $token); $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_CUSTOMREQUEST => $verb, CURLOPT_HTTPHEADER => $headers, CURLOPT_POSTFIELDS => json_encode($payload))); $response = json_decode(curl_exec($ch)); $logger->debug("Response was: " . print_r($response, true)); curl_close($ch); return $response; }
function send_curl_request($isProvider, $token, $verb, $url, $payload = '') { // getting access to the logger $logger = \APS\LoggerRegistry::get(); $headers = array('Content-type: application/json', ($isProvider ? 'x-provider-token: ' : 'x-company-token: ') . $token); $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_CUSTOMREQUEST => $verb, CURLOPT_HTTPHEADER => $headers, CURLOPT_POSTFIELDS => json_encode($payload))); $response = json_decode(curl_exec($ch)); // if loglevel is set to debug this info will be written to /var/log/httpd/ssl_error_log // APS_DEVELOPMENT_MODE is set to true in city.php $logger->debug("Response was: " . print_r($response, true)); curl_close($ch); return $response; }
private function send_curl_request($verb, $url, $payload = array("type" => "container")) { $logger = \APS\LoggerRegistry::get(); $application_response = APS\Request::getController()->getIo()->sendRequest(\APS\Proto::GET, "/aps/2/resources/" . $this->subscription_service->aps->id . "/application"); $application = json_decode($application_response); $token = $application[0]->token; $headers = array('x-reseller-token: ' . $token); $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_CUSTOMREQUEST => $verb, CURLOPT_HTTPHEADER => $headers, CURLOPT_POSTFIELDS => json_encode($payload))); $response = json_decode(curl_exec($ch)); $logger->debug("Response was: " . print_r($response, true)); curl_close($ch); return $response; }