承接 verifymycontent/video-moderation 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

verifymycontent/video-moderation

Composer 安装命令:

composer require verifymycontent/video-moderation

包简介

Content Moderation SDK

README 文档

README

PHP SDK to use the VerifyMyContent Video Moderation service.

Installation

composer require verifymycontent/video-moderation

Get Started

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

Start a Moderation

Use the start method to create a moderation, like the example below:

<?php

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

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

$response = $moderation->start(new \VerifyMyContent\SDK\ContentModeration\Entity\Requests\CreateStaticContentModerationRequest([
  "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",
  "customer" => [
    "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 Moderation by ID

Retrieves a specific moderation to get current status. Example:

<?php

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

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

$response = $moderation->get($moderationID);

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

Live Stream

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

Create a Live Stream Moderation

Use the createLivestream method to create a live stream moderation, like the example below:

<?php

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

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

$response = $moderation->createLivestream(new \VerifyMyContent\SDK\ContentModeration\Entity\Requests\CreateLiveContentModerationRequest([
  "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"
  ]
]));

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

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

Start a created Live Stream 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 startLivestream method to trigger the moderation:

<?php

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

$success = $moderation->startLivestream($_GET['id'], new \VerifyMyContent\SDK\ContentModeration\Entity\Requests\StartLiveContentModerationRequest([
    "embed_url" => "https://example.com/live-stream-embed",
    "stream" => [
        "protocol" => "rtmps",
        "url" => "rtmps://your-server:443/your-video-stream"
    ],
]));
var_dump($success === true);

Note: You'll have a limit of time to send this request after you received the webhook notifying the user was authorised to start the broadcast.

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");
    
$moderation = new VerifyMyContent\VideoModeration\Moderation(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));
//$moderation->useSandbox();

$success = $moderation->changeLivestreamRule($_GET['id'], new \VerifyMyContent\SDK\ContentModeration\Entity\Requests\ChangeLiveContentRuleRequest([
  "rule" => "no-nudity"
]));
var_dump($success === true);

Complaint Resolution

To start a complaint for previously uploaded content. You need to send the original content and the violations raised by the user.

Create a Complaint Moderation

Use the createComplaintModeration method to create a complaint moderation, like the example below:

<?php

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

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

$response = $moderation->createComplaintModeration(new \VerifyMyContent\SDK\Complaint\Entity\Requests\CreateStaticContentComplaintRequest([
   "content" => [
      "description" => "Your description", 
      "external_id" => "YOUR-VIDEO-ID", 
      "tags" => [
          "VIOLATION_1" 
      ], 
      "title" => "Your title", 
      "type" => "video", 
      "url" => "https://example.com/video.mp4" 
   ], 
   "customer" => [
      "id" => "YOUR-USER-ID" 
   ], 
   "webhook" => "https://example.com/webhook" 
]));

var_dump($response);

Create a Live Stream Complaint Moderation

Use the createComplaintLivestream method to create a live stream complaint moderation, like the example below:

<?php

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

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

$response = $moderation->createComplaintLivestream(new \VerifyMyContent\SDK\Complaint\Entity\Requests\CreateLiveContentComplaintRequest([
   "complained_at" => "2022-11-04T12:04:08.658Z", 
   "customer" => [
      "id" => "YOUR-USER-ID" 
   ], 
   "stream" => [
      "external_id" => "YOUR-LIVESTREAM-ID", 
      "tags" => [
        "VIOLATION_1" 
      ]
   ], 
   "webhook" => "https://example.com/webhook" 
]));

var_dump($response);

Create a Consent Complaint

Use the createComplaintConsent method to create a complaint consent moderation, like the example below:

<?php

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

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

$response = $moderation->createComplaintConsent(new \VerifyMyContent\SDK\Complaint\Entity\Requests\CreateConsentComplaintRequest([
   "content" => [
      "external_id" => "YOUR-VIDEO-ID" 
   ], 
   "customer" => [
      "id" => "YOUR-USER-ID" 
   ], 
   "webhook" => "https://example.com/webhook"
]));

var_dump($response);

Webhook Security

In order to confirm that a webhook POST was sent from VerifyMyContent, we provide a helper class to validate that the Authorization header was sent correctly. Example:

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

// get request body
$body = file_get_contents('php://input');
// get headers
$headers = getallheaders();
// instantiate VerifyMyContent helper class
$hmac = new VerifyMyContent\Commons\Security\HMAC(getenv('VMC_API_KEY'), getenv('VMC_API_SECRET'));
// validate hmac Authorization
if(!array_key_exists('Authorization', $headers) || !$hmac->validate($headers['Authorization'], $body)) {
  die("This request did not come from VerifyMyContent");
}
// you can do your logic now, the webhook was called from VerifyMyContent.
var_dump($body);

verifymycontent/video-moderation 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 26.42k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 30
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

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