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

发布于 2024-12-22 01:23:34 字数 1506 浏览 2 评论 0 原文

我复制并粘贴了用于基于浏览器上传的示例 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 上传表单的下拉菜单中复制并粘贴“游戏”一词,但无济于事(我不是绝望吗)。

有谁知道为什么会发生这种情况?

I copied and pasted the example YouTube api code for browser-based uploading to my website, but it appears when I change the category to "Gaming", it gives me a bad request error.

Here is the example code:

$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'];

However, when I change

$myVideoEntry->setVideoCategory('Autos');

to

$myVideoEntry->setVideoCategory('Gaming');

I get..

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>

I have identified this as the only error. I have tried copying and pasting the word Gaming from the dropdown menu on the actual youtube upload form, to no avail (aren't I desperate).

Does anyone have any clue why this is happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天 2024-12-29 01:23:34

我查看了您收到的错误,发现有一个网址 (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>

所以我会尝试使用“游戏”一词而不是“游戏”。

$myVideoEntry->setVideoCategory('Games');

I took a look into the error you got, and there was an url (http://gdata.youtube.com/schemas/2007/categories.cat) in it. I downloaded the file and found the following line:

<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>

So I would try the term Games instead of Gaming.

$myVideoEntry->setVideoCategory('Games');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文