Skip to content

Instantly share code, notes, and snippets.

@sanchezcarlosjr
Created November 14, 2020 16:20
Show Gist options
  • Save sanchezcarlosjr/dcbc85f12f0f09f705fd31a28d95b9f2 to your computer and use it in GitHub Desktop.
Save sanchezcarlosjr/dcbc85f12f0f09f705fd31a28d95b9f2 to your computer and use it in GitHub Desktop.
CURP API - Government infraestructure
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://us-west4-arsus-production.cloudfunctions.net/curp?curp=CAHF620818HMNLNL09&apiKey=pT32raieZC3');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment