Skip to content

Instantly share code, notes, and snippets.

@carloslopez1990
Created August 17, 2016 08:47
Show Gist options
  • Save carloslopez1990/873b4fe8fc3aff8d9e49aca53150b35f to your computer and use it in GitHub Desktop.
Save carloslopez1990/873b4fe8fc3aff8d9e49aca53150b35f to your computer and use it in GitHub Desktop.
Obtiene Info de Cédula desde el CSE
<?php
# Obtiene Info de Cédula desde el CSE
# By Carlos Ernesto López | Junio 2, 2015
# https://github.com/carloslopez1990/info_cedula_cse
$cedula = str_replace( array( ' ', '-' ), '', $_REQUEST['cedula'] );
if( !preg_match('|^[0-9]{13}[a-zA-Z]{1}$|', $cedula) )
exit('ERROR: CEDULA INVALIDA');
$ch = curl_init('http://www.cse.gob.ni/buscarcv.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('cedula' => $cedula,
'tipo' => 'C'));
$info = curl_exec($ch);
function get( $pattern ) {
global $info;
preg_match_all('|'.$pattern.'|is', $info, $matches);
return trim($matches[1][0]);
}
$final = array(
'nombre' => get('<b>NOMBRE:</b> (.*?) <'),
'expediente_colilla' => get('<b>EXPEDIENTE / COLILLA:</b> (.*?) <'),
'cv' => get('<b>CV:</b> (.*?) <'),
'departamento' => get('<b>DEPARTAMENTO:</b> (.*?) <br>'),
'municipio' => get('<b>MUNICIPIO:</b> (.*?) <'),
'ubicacion' => get('<b>UBICACION:</b> (.*?) <'),
'direccion' => get('<b>DIRECCION:</b> (.*?) <'),
);
print json_encode( $final );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment