bdelespierre/onfido-api-php-client

Onfido API 用于提交检查请求。

5.2.1 2021-12-01 16:45 UTC

README

Onfido API 用于提交检查请求。

此 PHP 包是由 OpenAPI Generator 项目自动生成的

  • API 版本:3.0.0
  • 包版本:5.2.0
  • 构建包:org.openapitools.codegen.languages.PhpClientCodegen

要求

  • PHP 7.1 及以上版本
  • Guzzle/psr7 1.7 及以上版本

安装与使用

Composer

要使用 Composer 安装绑定,请将以下内容添加到 composer.json

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/onfido/api-php-client.git"
    }
  ],
  "require": {
    "onfido/api-php-client": "^5.2.0"
  }
}

然后运行 composer install

手动安装

下载文件并包含 autoload.php

    require_once('/path/to/onfido-php/vendor/autoload.php');

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门指南

请按照 安装过程 进行,然后运行以下命令

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure 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());
}

?>

API 端点文档

所有 URI 都相对于 https://api.onfido.com/v3

模型文档

授权文档

令牌

  • 类型:API 密钥
  • API 密钥参数名:Authorization
  • 位置:HTTP 头部

作者