1

ブラウザベースのアップロード用のサンプル YouTube API コードをコピーして自分の Web サイトに貼り付けましたが、カテゴリを「ゲーム」に変更すると表示され、不正なリクエスト エラーが発生します。

コード例は次のとおりです。

$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という単語をコピーして貼り付けようとしましたが、役に立ちませんでした(必死ではありませんか)。

なぜこれが起こっているのか、誰にも手がかりがありますか?

4

1 に答える 1

5

表示されたエラーを調べたところ、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>

だから私はゲームの代わりにゲームという用語を試してみます.

$myVideoEntry->setVideoCategory('Games');
于 2011-12-21T11:46:36.087 に答える