เรากำลังอัปเดต Data API ให้สอดคล้องกับวิธีที่ YouTube นับยอดดูสำหรับ Shorts
ดูข้อมูลเพิ่มเติม
Activities: insert
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
โพสต์กระดานข่าวสำหรับช่องที่เฉพาะเจาะจง (ผู้ใช้ที่ส่งคำขอต้องได้รับอนุญาตให้ดำเนินการในนามของช่อง)
หมายเหตุ: แม้ว่าทรัพยากร activity
จะมีข้อมูลเกี่ยวกับการดำเนินการต่างๆ เช่น ผู้ใช้ให้คะแนนวิดีโอหรือทำเครื่องหมายวิดีโอเป็นรายการโปรด แต่คุณต้องใช้วิธีการ API อื่นๆ เพื่อสร้างทรัพยากร activity
เหล่านั้น เช่น คุณจะใช้วิธี videos.rate()
ของ API เพื่อจัดเรตวิดีโอ และใช้วิธี playlistItems.insert()
เพื่อทำเครื่องหมายวิดีโอเป็นรายการโปรด
ผลกระทบต่อโควต้า: การเรียกใช้เมธอดนี้มีต้นทุนโควต้า 50 หน่วย
ส่งคำขอ
คำขอ HTTP
POST https://www.googleapis.com/youtube/v3/activities
พารามิเตอร์
ตารางต่อไปนี้แสดงพารามิเตอร์ที่การค้นหานี้รองรับ พารามิเตอร์ทั้งหมดที่แสดงคือพารามิเตอร์การค้นหา
พารามิเตอร์ |
พารามิเตอร์ที่จำเป็น |
part |
string
พารามิเตอร์ part มีไว้สำหรับวัตถุประสงค์ 2 ประการในการดำเนินการนี้ โดยจะระบุพร็อพเพอร์ตี้ที่การดำเนินการเขียนจะตั้งค่า รวมถึงพร็อพเพอร์ตี้ที่การตอบกลับของ API จะรวมไว้ด้วย
รายการต่อไปนี้มีpart ชื่อที่คุณรวมไว้ในค่าพารามิเตอร์ได้
contentDetails
id
snippet
|
เนื้อความของคำขอ
ระบุทรัพยากรกิจกรรมในเนื้อหาคำขอ
สำหรับแหล่งข้อมูลนั้น ให้ทำดังนี้
ข้อผิดพลาด
ตารางต่อไปนี้ระบุข้อความแสดงข้อผิดพลาดที่ API อาจแสดงเพื่อตอบสนองต่อการเรียกใช้เมธอดนี้ โปรดดูรายละเอียดเพิ่มเติมในเอกสารประกอบข้อความแสดงข้อผิดพลาด
ประเภทข้อผิดพลาด |
รายละเอียดข้อผิดพลาด |
คำอธิบาย |
badRequest (400) |
bulletinTextRequired |
คำขอต้องใช้วัตถุ snippet ของพร็อพเพอร์ตี้ description เพื่อระบุข้อความสำหรับโพสต์ประกาศ |
badRequest (400) |
invalidMetadata |
พร็อพเพอร์ตี้ kind ไม่ตรงกับประเภทรหัสที่ระบุ |
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 Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-21 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"]],["อัปเดตล่าสุด 2025-08-21 UTC"],[[["\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,["# Activities: insert\n\n**YouTube has deprecated the channel bulletin feature, and this method is no longer supported.** \n\nFor more details, please see the [YouTube Help Center](https://support.google.com/youtube?p=channel-bulletins).\nPosts a bulletin for a specific channel. (The user submitting the request must be authorized to act on the channel's behalf.) \n\n**Note:** Even though an `activity` resource can contain information about actions like a user rating a video or marking a video as a favorite, you need to use other API methods to generate those `activity` resources. For example, you would use the API's [videos.rate()](/youtube/v3/docs/videos/rate) method to rate a video and the [playlistItems.insert()](/youtube/v3/docs/playlistItems/insert) method to mark a video as a favorite.\n\n**Quota impact:** A call to this method has a [quota cost](/youtube/v3/getting-started#quota) of 50 units.\n\nRequest\n-------\n\n### HTTP request\n\n```\nPOST https://www.googleapis.com/youtube/v3/activities\n```\n\n### Authorization\n\nThis request requires authorization with at least one of the following scopes ([read more about authentication and authorization](/youtube/v3/guides/authentication)).\n\n| Scope |\n|-----------------------------------------------------|\n| `https://www.googleapis.com/auth/youtube` |\n| `https://www.googleapis.com/auth/youtube.force-ssl` |\n\n### Parameters\n\nThe following table lists the parameters that this query supports. All of the parameters listed are query parameters.\n\n| Parameters ||\n|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| **Required parameters** |||\n| `part` | `string` The **part** parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. The following list contains the `part` names that you can include in the parameter value: - `contentDetails` - `id` - `snippet` |\n\n### Request body\n\nProvide an [activity resource](/youtube/v3/docs/activities#resource) in the request body.\nFor that resource:\n\n- You must specify a value for these properties:\n\n - `snippet.description`\n- You can set values for these properties:\n\n - `snippet.description`\n - `contentDetails.bulletin.resourceId`\n\nResponse\n--------\n\nIf successful, this method returns an [activity resource](/youtube/v3/docs/activities#resource) in the response body.\n\nErrors\n------\n\nThe following table identifies error messages that the API could return in response to a call to this method. Please see the [error message](/youtube/v3/docs/errors) documentation for more detail.\n\n| Error type | Error detail | Description |\n|-------------------------------|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `badRequest (400)` | `bulletinTextRequired` | The request must use the `snippet` object's `description` property to provide the text for the bulletin post. |\n| `badRequest (400)` | `invalidMetadata` | The `kind` property does not match the type of ID provided. |\n| `forbidden (403)` | `forbidden` | The request is not properly authorized. |\n| `notFound (404)` | `playlistNotFound` | YouTube cannot find the video that you are trying to associate with the bulletin post. Check the value of the `contentDetails.bulletinPosted.playlistId` property. |\n| `notFound (404)` | `videoNotFound` | YouTube cannot find the video that you are trying to associate with the bulletin post. Check the value of the `contentDetails.bulletinPosted.videoId` property. |\n| `userRateLimitExceeded (403)` | `rateLimitExceeded` | The request cannot be completed because you have exceeded your [quota](/youtube/v3/getting-started#quota). |"]]