訂閱推播通知
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
YouTube Data API (v3) 支援透過 PubSubHubbub 傳送推播通知,PubSubHubbub 是適用於網路存取資源的伺服器對伺服器發布/訂閱通訊協定。系統會透過 HTTP Webhook 將通知推送至訂閱者,比起輪詢型解決方案更有效率。有了 PubSubHubbub 時,您的伺服器就能以近乎即時的方式找出事件,不必判斷最佳輪詢間隔,或重複擷取未變更的資料。
當頻道進行下列任何活動時,PubSubHubbub 回呼伺服器會收到 Atom 動態消息通知:
下列步驟說明如何訂閱通知:
-
設定可處理收到的 Atom 動態消息通知的回呼伺服器。
-
前往 Google 中心訂閱推播通知:
-
傳送至回呼伺服器的程序通知。通知的格式如下所示。請注意,您可以使用 <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>
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2023-10-26 (世界標準時間)。
[[["容易理解","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 (世界標準時間)。"],[[["\u003cp\u003eThe YouTube Data API v3 uses PubSubHubbub for push notifications, enabling near real-time updates without the need for constant polling.\u003c/p\u003e\n"],["\u003cp\u003eYour server will receive notifications when a YouTube channel uploads a video or updates a video's title or description.\u003c/p\u003e\n"],["\u003cp\u003eTo 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.\u003c/p\u003e\n"],["\u003cp\u003eNotifications are sent as Atom feeds, and the \u003ccode\u003e<yt:videoId>\u003c/code\u003e and \u003ccode\u003e<yt:channelId>\u003c/code\u003e elements within these feeds can be used to identify the specific video and channel.\u003c/p\u003e\n"]]],["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"],null,[]]