我们正在更新 Data API,以便与 YouTube 统计 Shorts 短视频观看次数的方式保持一致。
了解详情
实现:activity
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
以下示例展示了如何使用 YouTube Data API (v3) 执行与用户活动相关的函数。
检索渠道活动列表
检索订阅活动列表
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-11-23。
[null,null,["最后更新时间 (UTC):2024-11-23。"],[[["\u003cp\u003eYouTube is removing the channel bulletin feature, which impacts how channel activity is managed.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eactivities.insert\u003c/code\u003e method will be deprecated, and \u003ccode\u003eactivities.list\u003c/code\u003e will no longer return channel bulletins after May 18, 2020.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve a list of channel activities using the \u003ccode\u003eactivities.list\u003c/code\u003e method by either setting the \u003ccode\u003emine\u003c/code\u003e parameter to \u003ccode\u003etrue\u003c/code\u003e for the authenticated user or by specifying a \u003ccode\u003echannelId\u003c/code\u003e for a particular channel.\u003c/p\u003e\n"],["\u003cp\u003eTo view subscription activities for the authenticated user, you must use the \u003ccode\u003eactivities.list\u003c/code\u003e method with the \u003ccode\u003ehome\u003c/code\u003e parameter set to \u003ccode\u003etrue\u003c/code\u003e.\u003c/p\u003e\n"]]],["YouTube is removing the channel bulletin feature. Consequently, the `activities.insert` method will be deprecated, and `activities.list` will no longer return channel bulletins, effective on or after May 18, 2020. The `activities.list` method can still be used to retrieve channel activities by setting `mine=true` for the authenticated user's activities or using the `channelId` parameter. You can also retrieve subscription activities by setting `home=true`.\n"],null,["# Implementation: Activities\n\nYouTube is deprecating the channel bulletin feature. As a result, the [activities.insert](/youtube/v3/docs/activities/insert) method will be deprecated, and the [activities.list](/youtube/v3/docs/activities/list) method will stop returning channel bulletins. These changes will be effective in the API on or after May 18, 2020. For more details, please see the [YouTube Help Center](https://support.google.com/youtube?p=channel-bulletins).\n\nThe following examples show how to use the YouTube Data API (v3) to perform functions related to user activity.\n\nRetrieve a list of channel activities\n-------------------------------------\n\nTo retrieve a list of events related to a particular channel, call the [activities.list](/youtube/v3/docs/activities/list) method using one of the following two methods to identify the channel:\n\n- Set the [mine](/youtube/v3/docs/activities/list#mine) parameter value to `true` to retrieve a list of the currently authenticated user's activities. Your request must be authorized using OAuth 2.0.\n\n ```\n https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.activities.list?\n part=snippet,contentDetails\n &mine=true\n ```\n- Set the [channelId](/youtube/v3/docs/activities/list#channelId) parameter to the YouTube channel ID that uniquely identifies the channel for which you are retrieving an activity list. This example sets the `channelId` parameter to `UCK8sQmJBp8GCxrOtXWBpyEA`, which also identifies Google's official YouTube channel.\n\n ```\n https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.activities.list?\n part=snippet,contentDetails\n &channelId=UCK8sQmJBp8GCxrOtXWBpyEA\n ```\n\nRetrieve a list of subscription activities\n------------------------------------------\n\nSubscription activities refer to events associated with channels that the authenticated user subscribes to. To retrieve a list of subscription activities for the currently authenticated user, call the [activities.list](/youtube/v3/docs/activities/list) method and set the [home](/youtube/v3/docs/activities/list#home) parameter's value to `true`. The request must be authorized using OAuth 2.0. \n\n```\nhttps://developers.google.com/apis-explorer/#p/youtube/v3/youtube.activities.list?\n part=snippet,contentDetails\n &home=true\n```"]]