function getCURL($url){ $tmp_fname = tempnam("tmp", "COOKIE"); $ch = curl_init($url); curl_setopt($ch, CURLOPT_COOKIEJAR, $tmp_fname); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/json")); $result = curl_exec($ch); curl_close($ch); unlink($tmp_fname); return $result; } function busca_cep($cep){ $url = "http://api.postmon.com.br/v1/cep/{$cep}"; return getCURL($url); } die(busca_cep($_REQUEST['cep']));