Skip to content

Instantly share code, notes, and snippets.

@rcarvs
Created January 19, 2019 21:00
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 rcarvs/585b7fa95d9a2db65d0daf1431f3d7bf to your computer and use it in GitHub Desktop.
Save rcarvs/585b7fa95d9a2db65d0daf1431f3d7bf to your computer and use it in GitHub Desktop.
Verifica se determinado CPF é servidor público federal ou não consultando o portal da transparência.
<?php
/*
* @author carvs
*/
$cpf = "12345678912";
$url = "http://transparencia.gov.br/servidores/Servidor-ListaServidores.asp?bogus=1&Pagina=1&TextoPesquisa=".$cpf;
$opts = array('http' =>
array(
'method' => 'GET',
'timeout' => 20
)
);
$context = stream_context_create($opts);
$retorno = file_get_contents($url, false, $context);
$explode = explode(' ',$retorno);
$servidor = false;
if(!in_array("encontrados", $explode)){
$servidor = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment