Youtube API - 请求元数据指定无效的视频说明

时间:2017-05-26 02:37:00

标签: php youtube-api

我知道这个问题是重复的,但现象却不同。

我使用Youtube API PHP上传我的视频。不幸的是,它发现了错误:

{
    "status": "fail",
    "mess": "Failed to start the resumable upload (HTTP 400: youtube.video, The request metadata specifies an invalid video description.)"
}

我检查了说明。使用mb_strlen()返回小于5000个字符的结果。

$title = mb_substr($title, 0, 100);
$description = mb_substr($description , 0, 4999);
$tags = array_slice($tags, 0, 15);

$snippet = new Google_Service_YouTube_VideoSnippet();
$snippet->setTitle($title);
$snippet->setDescription($description);
$snippet->setTags($tags);
$snippet->setCategoryId("22");

$status = new Google_Service_YouTube_VideoStatus();
$status->privacyStatus = "public";

$video = new Google_Service_YouTube_Video();
$video->setSnippet($snippet);
$video->setStatus($status);

存在一些特殊字符:<>|'(单个qoute),()?"(double引用)。
我研究了这个错误,但没有任何结果:(

1 个答案:

答案 0 :(得分:0)

您需要从描述中删除所有< >个字符。

$description = str_replace(['>', '<'], '', $description);
$snippet->setDescription($description);