PHP code example of bdelespierre / onfido-api-php-client
1. Go to this page and download the library: Download bdelespierre/onfido-api-php-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bdelespierre / onfido-api-php-client example snippets
onfigure API key authorization: Token
$config = Onfido\Configuration::getDefaultConfiguration();
$config->setApiKey('Authorization', 'token=' . 'YOUR API KEY');
$config->setApiKeyPrefix('Authorization', 'Token');
// Limit the at-rest region, if needed (optional, see https://documentation.onfido.com/#regions)
// $config->setHost($config->getHostFromSettings(1, array("region" => "us")));
$apiInstance = new Onfido\Api\DefaultApi(null, $config);
// Setting applicant details
$applicantDetails = new Onfido\Model\Applicant();
$applicantDetails->setFirstName('Jane');
$applicantDetails->setLastName('Doe');
$applicantDetails->setDob('1990-01-31');
$address = new \Onfido\Model\Address();
$address->setBuildingNumber('100');
$address->setStreet('Main Street');
$address->setTown('London');
$address->setPostcode('SW4 6EH');
$address->setCountry('GBR');
$applicantDetails->setAddress($address);
// Setting check details
$checkData = new Onfido\Model\Check();
$checkData->setReportNames(array('identity_standard'));
// Create an applicant and then a check with an Identity report
try {
$applicantResult = $apiInstance->createApplicant($applicantDetails);
$applicantId = $applicantResult->getId();
print_r("Applicant ID: ".$applicantId);
$checkData->setApplicantId($applicantId);
$checkResult = $apiInstance->createCheck($checkData);
print_r($checkResult);
} catch (Exception $e) {
print_r($e->getResponseBody());
}