Skip to content

Instantly share code, notes, and snippets.

@madeinnordeste
Created November 22, 2023 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madeinnordeste/26ecae7ec7a78bcdbd94eb9024bc3d78 to your computer and use it in GitHub Desktop.
Save madeinnordeste/26ecae7ec7a78bcdbd94eb9024bc3d78 to your computer and use it in GitHub Desktop.
via cep api
public function consultZip($zip)
{
$client = new Client(["http://viacep.com.br/ws/" . $zip . "/json/"]);
$result = $client->request('get', "http://viacep.com.br/ws/" . $zip . "/json/", ['Accept' => 'application/json']);
$output = $result->getBody()->getContents();
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment