显然“Gaming"不是一个有效的YouTube类别


Apparently "Gaming" is not a valid youtube category

我复制并粘贴了用于基于浏览器上传的示例YouTube api代码到我的网站,但当我将类别更改为"Gaming"时,它会出现一个严重的请求错误。

下面是示例代码:
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$myVideoEntry->setVideoTitle('My Test Movie');
$myVideoEntry->setVideoDescription('My Test Movie');
// The category must be a valid YouTube category!
$myVideoEntry->setVideoCategory('Autos');
// Set keywords. Please note that this must be a comma-separated string
// and that individual keywords cannot contain whitespace
$myVideoEntry->SetVideoTags('cars, funny');
$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
$tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
$tokenValue = $tokenArray['token'];
$postUrl = $tokenArray['url'];
然而,当我改变
$myVideoEntry->setVideoCategory('Autos');

$myVideoEntry->setVideoCategory('Gaming');

我. .

Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400 <?xml version='1.0' encoding='UTF-8'?><errors><error><domain>yt:validation</domain><code>invalid_value</code><location type='xpath'>media:group/media:category[@scheme='http://gdata.youtube.com/schemas/2007/categories.cat']/text()</location></error></errors>

我已经确定这是唯一的错误。我试着从下拉菜单中复制和粘贴游戏这个词在实际的youtube上传表单上,但无济于事(我不是很绝望)。

有人知道为什么会这样吗?

我看了一下你得到的错误,里面有一个url (http://gdata.youtube.com/schemas/2007/categories.cat)。我下载了这个文件,发现了下面一行:

<atom:category term='Games' label='Gaming' xml:lang='en-US'><yt:assignable/><yt:browsable regions='AR AU BD BE BG BR CA CO CZ DE DK DZ EE EG ES ET FI FR GB GR HK HR HU ID IE IL IN IR IS IT JO JP KE KR LT LV MA MX MY NG NL NO NZ PH PK PL PT RO RS RU SA SE SG SI SK TH TN TR TW TZ UA UG US VN YE ZA'/></atom:category>

所以我会用"Games"这个词来代替"Gaming"。

$myVideoEntry->setVideoCategory('Games');