Skip to content

Instantly share code, notes, and snippets.

@wescleymatos
Created January 5, 2012 14:00
Show Gist options
  • Save wescleymatos/1565377 to your computer and use it in GitHub Desktop.
Save wescleymatos/1565377 to your computer and use it in GitHub Desktop.
Implementação para o webservice para servir cep do republica virtual
<?php
header('Content-type: application/json');
$cep = $_GET['cep'];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://cep.republicavirtual.com.br/web_cep.php?formato=javascript&cep=' . $cep,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true)
);
$request = curl_exec($curl);
curl_close($curl);
$trans = array("%E1" => "á", "%E9" => "é", "%ED" => "í", "%F3" => "ó","%FA" => "ú", "%D1" => "ñ", "%A1" => "Á", "%A9" => "É", "%AD" => "Í", "%B3" => "Ó" , "%BA" => "Ú", "%F1" => "ñ", "%E7" => "ç", "%20" => " ");
$request = substr($request,24);
$request = str_replace("'",'"',$request);
$request = strtr($request, $trans);
echo $request;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment