/** * @param string $url * @return ApiResultDto * * @todo allow for different return types * @todo use curl and post once the service actually requires authorization */ public function request($url = null) { /** * @var ApiResultDto $response */ if (is_null($url)) { $url = $this->getUrl(); } $output = null; $curl = curl_init(); //echo(__FILE__ . '(' . __LINE__ . ') $url: <pre>' . print_r($url, true)) . '</pre>'; curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_POSTFIELDS, $this->getParams()); $result = curl_exec($curl); curl_close($curl); //die(__FILE__ . '(' . __LINE__ . ') $result: <pre>' . print_r($result, true)) . '</pre>'; if ($response = json_decode($result)) { $output = new ApiResultDto(); $output->data = $response->data; $output->result = ApiResult::getFromValue($response->result); $output->msg = $response->msg; $output->version = $response->version; } return $output; }