Created
November 14, 2020 16:20
-
-
Save sanchezcarlosjr/dcbc85f12f0f09f705fd31a28d95b9f2 to your computer and use it in GitHub Desktop.
CURP API - Government infraestructure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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