我复制并粘贴了用于基于浏览器上传到我的网站的示例 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'];
然而,当我改变
$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 上传表单的下拉菜单中复制并粘贴单词 Gaming,但无济于事(我不是很绝望)。
有谁知道为什么会这样?