显然"游戏"不是有效的YouTube类别

Jar*_*red 1 php gdata-api youtube-api gdata zend-gdata

我将基于浏览器上传的示例YouTube api代码复制并粘贴到我的网站,但是当我将类别更改为"游戏"时,它会显示错误的请求错误.

这是示例代码:

$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'];
Run Code Online (Sandbox Code Playgroud)

但是,当我改变

$myVideoEntry->setVideoCategory('Autos');
Run Code Online (Sandbox Code Playgroud)

$myVideoEntry->setVideoCategory('Gaming');
Run Code Online (Sandbox Code Playgroud)

我明白了..

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>
Run Code Online (Sandbox Code Playgroud)

我已经确定这是唯一的错误.我试过从实际的YouTube上传表格的下拉菜单中复制并粘贴游戏这个词,但没有用(我不是绝望的).

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

Syn*_*der 5

我看了一下你得到的错误,里面有一个网址(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>
Run Code Online (Sandbox Code Playgroud)

所以我会尝试术语游戏而不是游戏.

$myVideoEntry->setVideoCategory('Games');
Run Code Online (Sandbox Code Playgroud)