verifymycontent/sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

verifymycontent/sdk

Composer 安装命令:

composer require verifymycontent/sdk

包简介

VerifyMyContent SDK

README 文档

README

PHP SDK to use the VerifyMyContent services (Identity Verification, Content Moderation, and Content Complaint).

Installation

composer require verifymycontent/sdk

Get Started

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

Start an Identity Verification

Use the createIdentityVerification of the VerifyMyContent\SDK\IdentityVerification\IdentityVerificationClient abstraction inside VerifyMyContent\VerifyMyContent passing an VerifyMyContent\SDK\IdentityVerification\Entity\Requests\CreateIdentityVerificationRequest and receiving an VerifyMyContent\SDK\IdentityVerification\Entity\Responses\CreateIdentityVerificationResponse.

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

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

$response = $vmc->identityVerification->createIdentityVerification(
    new \VerifyMyContent\SDK\IdentityVerification\Entity\Requests\CreateIdentityVerificationRequest([
        "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}");

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 of the VerifyMyContent\SDK\IdentityVerification\IdentityVerificationClient abstraction inside VerifyMyContent\VerifyMyContent.
  • Receive an VerifyMyContent\SDK\IdentityVerification\Entity\Responses\GetIdentityVerificationResponse.
<?php
require(__DIR__ . "/vendor/autoload.php");

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

$response = $vmc->identityVerification->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 the VerifyMyContent\SDK\IdentityVerification\Entity\Requests\WebhookIdentityVerificationRequest class.
<?php
require(__DIR__ . "/vendor/autoload.php");

$data = json_decode(file_get_contents('php://input'), true);
$webhook = new \VerifyMyContent\SDK\IdentityVerification\Entity\Requests\WebhookIdentityVerificationRequest($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

Use the createReIdentification of the VerifyMyContent\SDK\ReIdentification\ReIdentificationClient abstraction inside VerifyMyContent\VerifyMyContent passing a VerifyMyContent\SDK\ReIdentification\Entity\Requests\CreateReIdentificationRequest and receiving a VerifyMyContent\SDK\ReIdentification\Entity\Responses\CreateReIdentificationResponse.

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

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

$response = $vmc->reIdentification()->createReIdentification(
    new \VerifyMyContent\SDK\ReIdentification\Entity\Requests\CreateReIdentificationRequest([
        "customer" => [
            "id" => "YOUR-CUSTOMER-UNIQUE-ID",
            "email" => "person@example.com",
        ],
        "redirect_uri" => "https://example.com/callback",
        "webhook" => "https://example.com/webhook",
    ])
);

// save $response->id if you want to track this re-identification

// redirect user to re-identify
header("Location: {$response->redirect_uri}");

Retrieve Re-Identification by ID

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

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

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

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

Receive a Re-Identification Webhook

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

$data = json_decode(file_get_contents('php://input'), true);
$webhook = new \VerifyMyContent\SDK\ReIdentification\Entity\Requests\WebhookReIdentificationRequest($data);

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

Create a Static Content Moderation

Use the createStaticContentModeration of the VerifyMyContent\SDK\ContentModeration\ContentModerationClient abstraction inside VerifyMyContent\VerifyMyContent passing an VerifyMyContent\SDK\ContentModeration\Entity\Requests\CreateStaticContentModerationRequest and receiving an VerifyMyContent\SDK\ContentModeration\Entity\Responses\CreateStaticContentModerationResponse.

<?php

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

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

$response = $vmc->contentModeration()->createStaticContentModeration([
  "content" => [
    "type" => "video",
    "external_id" => "YOUR-VIDEO-ID",
    "url" => "https://example.com/video.mp4",
    "title" => "Uploaded video title",
    "description" => "Uploaded video description",
  ],
  "webhook" => "https://example.com/webhook",
  "redirect_url" => "https://example.com/callback",
  "customer" => [
    "id" => "YOUR-CUSTOMER-UNIQUE-ID",
    "email" => "person@example.com",
    "phone" => "+4412345678"
  ],
  "type" => "face-match",
  "rule" => "default",
  "faces_id" => ["ID"],
  "collection_id" => "YOUR-COLLECTION-ID",
  "participants" => [[
            "id" => "YOUR-CUSTOMER-UNIQUE-ID",
            "email" => "person@example.com",
            "phone" => "+4412345678"
  ]]
]);

// save $response->id if you want to call the moderation status endpoint later

// redirect uploader to check identity
header("Location: {$response->redirect_url}");

Retrieve Static Content Moderation by ID

Retrieves a specific moderation to get current status. Example:

  • Receive an VerifyMyContent\SDK\ContentModeration\Entity\Responses\GetStaticContentModerationResponse.
<?php

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

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

$response = $vmc->contentModeration()->getStaticContentModeration("YOUR-CONTENT-MODERATION-ID");

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

Receive a Static Content Moderation Webhook

  • Receive a webhook from VerifyMyContent with the $_POST data that can be parsed using the VerifyMyContent\SDK\ContentModeration\Entity\Requests\WebhookStaticContentModerationRequest class.
<?php
require(__DIR__ . "/vendor/autoload.php");

$data = json_decode(file_get_contents('php://input'), true);
$webhook = new \VerifyMyContent\SDK\ContentModeration\Entity\Requests\WebhookStaticContentModerationRequest($data);

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

// This is how you can check if the moderation was approved.
if ($webhook->status === \VerifyMyContent\SDK\ContentModeration\ContentModerationStatus::STATIC_APPROVED) {
    // do your thing
}

Live Content

To moderate a live stream broadcast you'll need to use different APIs as described below.

Create a Live Content Moderation

Use the createLiveContentModeration of the VerifyMyContent\SDK\ContentModeration\ContentModerationClient abstraction inside VerifyMyContent\VerifyMyContent passing an VerifyMyContent\SDK\ContentModeration\Entity\Requests\CreateLiveContentModerationRequest and receiving an VerifyMyContent\SDK\ContentModeration\Entity\Responses\CreateLiveContentModerationResponse.

<?php

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

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

$response = $vmc->contentModeration()->createLiveContentModeration([
  "external_id" => "YOUR-LIVESTREAM-ID",
  "embed_url" => "https://example.com/live/",
  "title" => "Live stream title",
  "description" => "Live stream description",
  "webhook" => "https://example.com/webhook",
  "stream" => [
      "protocol" => "webrtc",
      "url" => "https://example.com/live/",
  ],
  "customer" => [
      "id" => "YOUR-CUSTOMER-UNIQUE-ID",
      "email" => "person@example.com",
      "phone" => "+4412345678"
  ],
  "type" => "face-match",
  "rule" => "default",
  "faces_id" => ["ID"],
  "collection_id" => "YOUR-COLLECTION-ID"
]);

// save $response->id to start live stream later

// redirect uploader to check identity
header("Location: {$response->login_url}");

Start a created Live Content Moderation

When you receive the webhook with the status Authorised, it means you can now start to broadcast a live stream, you can then use the startLiveContentModeration method to trigger the moderation:

<?php

require(__DIR__ . "/vendor/autoload.php");
    
$vmc = new VerifyMyContent\VerifyMyContent(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));
//$vmc->useSandbox();

$vmc->contentModeration()->startLiveContentModeration("YOUR-CONTENT-MODERATION-ID");

// that's all folks!

Receive a Live Content Moderation Webhook

  • Receive a webhook from VerifyMyContent with the $_POST data that can be parsed using the VerifyMyContent\SDK\ContentModeration\Entity\Requests\WebhookLiveContentModerationRequest class.
<?php
require(__DIR__ . "/vendor/autoload.php");

$data = json_decode(file_get_contents('php://input'), true);
$webhook = new \VerifyMyContent\SDK\ContentModeration\Entity\Requests\WebhookLiveContentModerationRequest($data);

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

// This is how you can check if the live stream is authorized.
if ($webhook->status === \VerifyMyContent\SDK\ContentModeration\ContentModerationStatus::LIVE_AUTHORIZED
    // do your thing
}

Updating Live Stream moderation rules

This endpoint allows you to update the moderation rules for a specific live stream

<?php

require(__DIR__ . "/vendor/autoload.php");
    
$vmc = new VerifyMyContent\VerifyMyContent(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));
//$vmc->useSandbox();

$vmc->contentModeration()->changeLiveContentRule("YOUR-CONTENT-MODERATION-ID");

Pausing Live Stream moderation

This endpoint allows you to pause the moderation for a specific live stream

<?php

require(__DIR__ . "/vendor/autoload.php");
    
$vmc = new VerifyMyContent\VerifyMyContent(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));
//$vmc->useSandbox();

$vmc->contentModeration()->pauseLivestream("YOUR-CONTENT-MODERATION-ID");

Resume Live Stream moderation

This endpoint allows you to resume the moderation for a specific live stream

<?php

require(__DIR__ . "/vendor/autoload.php");
    
$vmc = new VerifyMyContent\VerifyMyContent(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));
//$vmc->useSandbox();

$vmc->contentModeration()->resumeLivestream("YOUR-CONTENT-MODERATION-ID");

verifymycontent/sdk 适用场景与选型建议

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

它主要适用于以下技术方向: 「php」 「api」 「sdk」 「identity」 「content」 「verification」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 21.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 16
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-22