我正在尝试使用 PHP 中的谷歌视频智能从 YouTube 视频中获取标签
这是我的代码
require __DIR__ . '/vendor/autoload.php';
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
use Google\Cloud\VideoIntelligence\V1\Feature;
use Google\Client;
$youTubeUrl = "***";
$videoIntelligenceServiceClient = new VideoIntelligenceServiceClient([
'credentials' => json_decode(file_get_contents('creds.json'), true)
]);
$features = [
Feature::LABEL_DETECTION,
];
$operationResponse = $videoIntelligenceServiceClient->annotateVideo([
'inputUri' => $youTubeUrl,
'features' => $features
]);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$results = $operationResponse->getResult();
foreach ($results->getAnnotationResults() as $result) {
var_dump($result);
}
}
返回错误
致命错误:未捕获 Google\ApiCore\ApiException: { "message": "请求包含无效参数。", "code": 3, "status": "INVALID_ARGUMENT", "details": [] }
有人知道为什么吗?
试试这个:
use Google\Cloud\VideoIntelligence\V1\Client\VideoIntelligenceServiceClient;