Activities: insert
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
为特定频道发布公告。(提交请求的用户必须获得授权才能代表频道行事。)
注意:虽然 activity
资源可以包含有关用户对视频进行评分或将视频标记为喜好视频等操作的信息,但您需要使用其他 API 方法来生成这些 activity
资源。例如,您可以使用该 API 的 videos.rate()
方法对视频进行评分,并使用 playlistItems.insert()
方法将视频标记为喜爱。
配额影响:对该方法的调用会产生 50 个单位的配额费用。
请求
HTTP 请求
POST https://www.googleapis.com/youtube/v3/activities
授权
此请求需要获得以下至少一个范围的授权(详细了解身份验证和授权)。
范围 |
https://www.googleapis.com/auth/youtube |
https://www.googleapis.com/auth/youtube.force-ssl |
参数
下表列出了此查询支持的参数。列出的所有参数均为查询参数。
参数 |
必需参数 |
part |
string
在此操作中,part 参数有两个用途。用于标识写入操作将设置的属性以及 API 响应将包含的属性。
以下列表包含您可以包含在参数值中的 part 名称:
contentDetails
id
snippet
|
请求正文
在请求正文中提供活动资源。
对于该资源:
-
您必须为以下属性指定值:
-
您可以为以下属性设置值:
snippet.description
contentDetails.bulletin.resourceId
响应
如果成功,此方法将在响应正文中返回一项活动资源。
错误
下表列出了 API 在响应对此方法的调用时可能会返回的错误消息。如需了解详情,请参阅错误消息文档。
错误类型 |
错误详情 |
说明 |
badRequest (400) |
bulletinTextRequired |
请求必须使用 snippet 对象的 description 属性来提供公告帖子的文本。 |
badRequest (400) |
invalidMetadata |
kind 属性与所提供的 ID 类型不匹配。 |
forbidden (403) |
forbidden |
相应请求未获得适当的授权。 |
notFound (404) |
playlistNotFound |
YouTube 找不到您尝试与公告帖子关联的视频。检查 contentDetails.bulletinPosted.playlistId 属性的值。 |
notFound (404) |
videoNotFound |
YouTube 找不到您尝试与公告帖子关联的视频。检查 contentDetails.bulletinPosted.videoId 属性的值。 |
userRateLimitExceeded (403) |
rateLimitExceeded |
由于您已超出配额,因此无法完成该请求。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-21。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-08-21。"],[[["\u003cp\u003eYouTube's channel bulletin feature has been deprecated and is no longer supported.\u003c/p\u003e\n"],["\u003cp\u003eCreating an activity requires authorization with specific scopes, such as \u003ccode\u003ehttps://www.googleapis.com/auth/youtube\u003c/code\u003e or \u003ccode\u003ehttps://www.googleapis.com/auth/youtube.force-ssl\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epart\u003c/code\u003e parameter in the request specifies which properties will be modified and included in the API response, such as \u003ccode\u003econtentDetails\u003c/code\u003e, \u003ccode\u003eid\u003c/code\u003e, and \u003ccode\u003esnippet\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe request body must include an activity resource, and it is required to provide a value for \u003ccode\u003esnippet.description\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThis method call has a quota cost of 50 units, and exceeding the quota will result in a \u003ccode\u003euserRateLimitExceeded\u003c/code\u003e error.\u003c/p\u003e\n"]]],["The YouTube channel bulletin feature is deprecated. The API's `activities.insert` method allows posting to a channel. This requires authorization and has a quota cost of 50 units. You must provide `snippet.description` for the bulletin text in the request body. Key parameters include `part`, and the response returns an `activity` resource. Errors can occur due to bad requests, invalid metadata, authorization issues, or exceeding quota limits.\n"],null,[]]