YouTube ショート動画の視聴回数のカウント方法に合わせて、Data API を更新します。
詳細
プッシュ通知に登録する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
YouTube Data API(v3)は、ウェブアクセス可能なリソースに対してサーバー間のパブリッシュ/サブスクライブ プロトコルを行う PubSubHubbub によるプッシュ通知をサポートしています。通知は HTTP Webhook を介してサブスクライバーにプッシュされるため、ポーリング ベースのソリューションよりもはるかに効率的です。PubSubHubbub を使用すると、サーバーは最適なポーリング間隔を決定したり、変化していないデータを繰り返し取得したりすることなく、ほぼリアルタイムでイベントを検出します。
PubSubHubbub コールバック サーバーは、チャンネルが次のいずれかのアクティビティを行うと、Atom フィード通知を受信します。
- 動画をアップロードした
- 動画のタイトルを更新する
- 動画の説明を更新したとき
通知を登録する手順は次のとおりです。
-
受信した Atom フィード通知を処理できるコールバック サーバーをセットアップします。
-
Google ハブを使用して、プッシュ通知の受信登録を行います。
-
[mode] を subscribe
に設定します。(または、モードを unsubscribe
に設定して定期購入を解約します)。
-
[コールバック URL] を、手順 1 で設定した URL に設定します。
-
トピック URL を https://www.youtube.com/feeds/videos.xml?channel_id=CHANNEL_ID
に設定します。ここで、CHANNEL_ID
は、プッシュ通知を取得する YouTube チャンネル ID です。
-
コールバック サーバーに送信された通知を処理します。通知の形式を以下に示します。<yt:videoId>
要素の値を使用すると、新しく追加または更新された動画を識別できます。<yt:channelId>
要素の値を使用して、その動画を所有するチャンネルを識別することもできます。
<feed xmlns:yt="http://www.youtube.com/xml/schemas/2015"
xmlns="http://www.w3.org/2005/Atom">
<link rel="hub" href="https://pubsubhubbub.appspot.com"/>
<link rel="self" href="https://www.youtube.com/xml/feeds/videos.xml?channel_id=CHANNEL_ID"/>
<title>YouTube video feed</title>
<updated>2015-04-01T19:05:24.552394234+00:00</updated>
<entry>
<id>yt:video:VIDEO_ID</id>
<yt:videoId>VIDEO_ID</yt:videoId>
<yt:channelId>CHANNEL_ID</yt:channelId>
<title>Video title</title>
<link rel="alternate" href="http://www.youtube.com/watch?v=VIDEO_ID"/>
<author>
<name>Channel title</name>
<uri>http://www.youtube.com/channel/CHANNEL_ID</uri>
</author>
<published>2015-03-06T21:40:57+00:00</published>
<updated>2015-03-09T19:05:24.552394234+00:00</updated>
</entry>
</feed>
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2023-10-26 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2023-10-26 UTC。"],[[["The YouTube Data API v3 uses PubSubHubbub for push notifications, enabling near real-time updates without the need for constant polling."],["Your server will receive notifications when a YouTube channel uploads a video or updates a video's title or description."],["To subscribe, set up a callback server, use the Google hub with the 'subscribe' mode, provide your callback URL, and specify the YouTube channel ID in the topic URL."],["Notifications are sent as Atom feeds, and the `\u003cyt:videoId\u003e` and `\u003cyt:channelId\u003e` elements within these feeds can be used to identify the specific video and channel."]]],["The YouTube Data API uses PubSubHubbub for push notifications, sending Atom feed updates to subscribers' HTTP webhooks when a channel uploads a video, or updates a video's title or description. To subscribe, set up a callback server, then use the Google hub with `subscribe` mode, your server's callback URL, and a YouTube channel's ID-specific topic URL. Notifications, sent as Atom feeds, include the video and channel IDs, as well as video titles and other information.\n"]]