定制 verifymycontent/identity-check 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

verifymycontent/identity-check

Composer 安装命令:

composer require verifymycontent/identity-check

包简介

VerifyMyContent Identity Check API SDK

README 文档

README

PHP SDK to use VerifyMyContent Identity-Check OAuth service.

Installation

composer require verifymycontent/identity-check

Get Started

The main class to handle the moderation integration process is the \VerifyMyContent\IdentityCheck\VMC. It will abstract the HMAC generation for the API calls.

Start an Identity Verification

<?php
require(__DIR__ . "/vendor/autoload.php");

$vmc = new \VerifyMyContent\IdentityCheck\VMC(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));
//$vmc->useSandbox();

try {
    $response = $vmc->createIdentityVerification([
            "customer" => [
                "id" => "YOUR-CUSTOMER-UNIQUE-ID",
                "email" => "person@example.com",
                "phone" => "+4412345678"
            ],
            "redirect_uri" => "https://example.com/callback",
            "webhook" => "https://example.com/webhook",
        ]
    );
    
    // save $response->id if you want to save the verification of your customer

    // redirect user to check identity
    header("Location: {$response->redirect_uri}");
} catch (Exception $e) {
  echo $e;
}

Retrieve Identity Verification by ID

Retrieves a specific identity verification to get current status.

  • Pass the id of the identity verification to the getIdentityVerification method.
  • Receive an \VerifyMyContent\SDK\IdentityVerification\Entity\Responses\GetIdentityVerificationResponse (library used internally by this sdk).
<?php
require(__DIR__ . "/vendor/autoload.php");

$vmc = new \VerifyMyContent\IdentityCheck\VMC(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));
//$vmc->useSandbox();

$response = $vmc->getIdentityVerification("YOUR-IDENTITY-VERIFICATION-ID");

// Printing current status
echo "Status: {$response->status}";

Receive an Identity Verification Webhook

Receive a webhook from VerifyMyContent when the identity verification status changes.

  • Receive a webhook from VerifyMyContent with the $_POST data that can be parsed using method parseIdentityVerificationWebhookPayload.
<?php
require(__DIR__ . "/vendor/autoload.php");

$vmc = new \VerifyMyContent\IdentityCheck\VMC(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));

$jsonPayload = '{
  "id": "ABC-123-5678-ABC",
  "customer_id": "customer_id",
  "status": "pending"
}';
$data = json_decode($jsonPayload, true);
$webhook = $vmc->parseIdentityVerificationWebhookPayload($data);

// Printing current status
echo "Status: {$webhook->status} received from verification {$webhook->id}";

// This is how you can check if the identity verification is approved.
if ($webhook->status === \VerifyMyContent\SDK\IdentityVerification\IdentityVerificationStatus::APPROVED) {
    // do your thing
}

Start a Re-Identification

<?php
require(__DIR__ . "/vendor/autoload.php");

$vmc = new \VerifyMyContent\IdentityCheck\VMC(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));
//$vmc->useSandbox();

try {
    $response = $vmc->createReIdentification([
        "customer" => [
            "id" => "YOUR-CUSTOMER-UNIQUE-ID",
            "email" => "person@example.com", // optional
        ],
        "redirect_uri" => "https://example.com/callback",
        "webhook" => "https://example.com/webhook",
    ]);

    // redirect user to re-identify
    header("Location: {$response->redirect_uri}");
} catch (\VerifyMyContent\SDK\ReIdentification\Exception\FeatureNotEnabledException $e) {
    echo "Re-identification feature not enabled for this account.";
} catch (\VerifyMyContent\SDK\ReIdentification\Exception\NoApprovedVerificationFoundException $e) {
    echo "No approved verification found for this customer.";
} catch (Exception $e) {
    echo $e;
}

Retrieve Re-Identification by ID

Retrieves a specific re-identification to get current status.

  • Pass the id of the re-identification to the getReIdentification method.
  • Receive an \VerifyMyContent\SDK\ReIdentification\Entity\Responses\GetReIdentificationResponse (library used internally by this sdk).
<?php
require(__DIR__ . "/vendor/autoload.php");

$vmc = new \VerifyMyContent\IdentityCheck\VMC(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));
//$vmc->useSandbox();

$response = $vmc->getReIdentification("YOUR-RE-IDENTIFICATION-ID");

// Printing current status
echo "Status: {$response->status}";

Receive a Re-Identification Webhook

<?php
require(__DIR__ . "/vendor/autoload.php");

$vmc = new \VerifyMyContent\IdentityCheck\VMC(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));

$data = json_decode(file_get_contents('php://input'), true);
$webhook = $vmc->parseReIdentificationWebhookPayload($data);

// Printing current status
echo "Status: {$webhook->status} received from re-identification {$webhook->id}";

Add allowed redirect urls

Update the list of allowed redirect urls

<?php
require(__DIR__ . "/vendor/autoload.php");

$vmc = new \VerifyMyContent\IdentityCheck\VMC(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));
$vmc->useSandbox();

try{
  $vmc->addAllowedRedirectUrls(["https://teste1.com", "https://teste2.com"]);
  echo "Urls replaced with success";
}catch(Exception $e){
  echo "Error";
  var_export($e);
}

Remove allowed redirect urls

Remove allowed redirect urls from the list

<?php
require(__DIR__ . "/vendor/autoload.php");

$vmc = new \VerifyMyContent\IdentityCheck\VMC(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));
$vmc->useSandbox();

try{
  $vmc->removeAllowedRedirectUrls(["https://teste1.com"]);
  echo "Urls removed with success";
}catch(Exception $e){
  echo "Error";
  var_export($e);
}

verifymycontent/identity-check 适用场景与选型建议

verifymycontent/identity-check 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24.04k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2021 年 11 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 verifymycontent/identity-check 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 verifymycontent/identity-check 我们能提供哪些服务?
定制开发 / 二次开发

基于 verifymycontent/identity-check 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 24.04k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 6
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-11-09