dpl74687 2011-12-21 11:36
浏览 21
已采纳

显然“游戏”不是有效的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?

  • 写回答

1条回答 默认 最新

  • duanmei4149 2011-12-21 11:46
    关注

    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');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM