/** * Chama uma servlet e devolve uma string * @param string $url * @param string $post string para postar Ex.: var1=val1&var2=val2 * @return string * @throws Exception */ public function getAsString($url, HttpPost $post = null) { $ch = curl_init($this->makeUrl($url)); if (!empty($post)) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post->get()); } curl_setopt($ch, CURLOPT_MUTE, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectionTimeOut); curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeOut); $result = curl_exec($ch); if (curl_errno($ch)) { throw new Exception(curl_error($ch), curl_errno($ch)); } curl_close($ch); return $result; }