PHP code example of google / cloud-videointelligence
1. Go to this page and download the library: Download google/cloud-videointelligence 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/ */
google / cloud-videointelligence example snippets
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest;
use Google\Cloud\VideoIntelligence\V1\AnnotateVideoResponse;
use Google\Cloud\VideoIntelligence\V1\Client\VideoIntelligenceServiceClient;
use Google\Rpc\Status;
// Create a client.
$videoIntelligenceServiceClient = new VideoIntelligenceServiceClient();
// Prepare the request message.
$request = new AnnotateVideoRequest();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $videoIntelligenceServiceClient->annotateVideo($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var AnnotateVideoResponse $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}