PHP code example of ltidev / video-moderation

1. Go to this page and download the library: Download ltidev/video-moderation 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/ */

    

ltidev / video-moderation example snippets




ration = 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" => "[email protected]",
    "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}");



ration = 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}";



ration = 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" => "[email protected]",
      "phone" => "+4412345678"
  ]
]));

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

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



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);



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);



ration = 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);



ration = 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);



ration = 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);


et 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);