ما در حال بهروزرسانی Data API هستیم تا با نحوه شمارش بازدیدهای YouTube برای Shorts مطابقت داشته باشد.
بیشتر بدانید
Comments: list
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
فهرستی از نظرات منطبق با پارامترهای درخواست API را برمیگرداند.
تاثیر سهمیه ای: فراخوانی به این روش هزینه سهمیه ای 1 واحدی دارد.
موارد استفاده رایج
درخواست
درخواست HTTP
GET https://www.googleapis.com/youtube/v3/comments
مولفه های
جدول زیر پارامترهایی را که این کوئری پشتیبانی می کند فهرست می کند. تمام پارامترهای لیست شده پارامترهای پرس و جو هستند.
مولفه های |
---|
پارامترهای مورد نیاز |
part | string پارامتر part یک لیست جدا شده با کاما از یک یا چند ویژگی منبع comment را مشخص می کند که پاسخ API شامل آن خواهد شد.
لیست زیر شامل نام part است که می توانید در مقدار پارامتر بگنجانید:
|
فیلترها (دقیقا یکی از پارامترهای زیر را مشخص کنید) |
id | string پارامتر id فهرستی از شناسه های نظر جدا شده با کاما را برای منابعی که بازیابی می شوند مشخص می کند. در یک منبع comment ، ویژگی id شناسه نظر را مشخص می کند. |
parentId | string پارامتر parentId شناسه نظری را مشخص میکند که پاسخها باید برای آن بازیابی شوند.
توجه: YouTube در حال حاضر از پاسخها فقط برای نظرات سطح بالا پشتیبانی میکند. با این حال، پاسخ به پاسخ ها ممکن است در آینده پشتیبانی شود. |
پارامترهای اختیاری |
maxResults | unsigned integer پارامتر maxResults حداکثر تعداد مواردی را که باید در مجموعه نتایج برگردانده شوند را مشخص می کند.
توجه: این پارامتر برای استفاده همراه با پارامتر id پشتیبانی نمی شود. مقادیر قابل قبول شامل 1 تا 100 است. مقدار پیش فرض 20 است. |
pageToken | string پارامتر pageToken صفحه خاصی را در مجموعه نتایج مشخص می کند که باید برگردانده شود. در یک پاسخ API، ویژگی nextPageToken صفحه بعدی نتیجه قابل بازیابی را مشخص می کند.
توجه: این پارامتر برای استفاده همراه با پارامتر id پشتیبانی نمی شود. |
textFormat | string این پارامتر نشان می دهد که آیا API باید نظراتی را که به صورت HTML فرمت شده اند یا به صورت متن ساده برگرداند. مقدار پیش فرض html است.
مقادیر قابل قبول عبارتند از:-
html - نظرات را در قالب HTML برمی گرداند. این مقدار پیش فرض است. -
plainText - نظرات را در قالب متن ساده برمی گرداند.
|
درخواست بدن
هنگام فراخوانی این روش، بدنه درخواست ارائه نکنید.
واکنش
در صورت موفقیت آمیز بودن، این روش یک بدنه پاسخ با ساختار زیر را برمی گرداند:
{
"kind": "youtube#commentListResponse",
"etag": etag,
"nextPageToken": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
comment Resource
]
}
خواص
جدول زیر ویژگی های ظاهر شده در این منبع را تعریف می کند:
خواص |
---|
kind | string نوع منبع API را مشخص می کند. مقدار youtube#commentListResponse خواهد بود. |
etag | etag Etag این منبع |
nextPageToken | string نشانه ای که می تواند به عنوان مقدار پارامتر pageToken برای بازیابی صفحه بعدی در مجموعه نتایج استفاده شود. |
pageInfo | object شی pageInfo اطلاعات صفحهبندی را برای مجموعه نتایج کپسوله میکند. |
pageInfo. totalResults | integer تعداد کل نتایج در مجموعه نتایج. |
pageInfo. resultsPerPage | integer تعداد نتایج موجود در پاسخ API. |
items[] | list فهرستی از نظراتی که با معیارهای درخواست مطابقت دارند. |
خطاها
جدول زیر پیام های خطایی را مشخص می کند که API می تواند در پاسخ به تماس با این روش بازگرداند. لطفاً برای جزئیات بیشتر به مستندات پیام خطا مراجعه کنید.
آن را امتحان کنید!
از APIs Explorer برای فراخوانی این API و مشاهده درخواست و پاسخ API استفاده کنید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2024-04-26 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-04-26 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Comments: list\n\nReturns a list of comments that match the API request parameters.\n\n**Quota impact:** A call to this method has a [quota cost](/youtube/v3/getting-started#quota) of 1 unit.\n\nCommon use cases\n----------------\n\nThe list below shows common use cases for this method. Hover over a use case to see its description, or click on a use case to load sample parameter values in the APIs Explorer. You can open the [fullscreen APIs Explorer](#) to see code samples that dynamically update to reflect the parameter values entered in the Explorer.\n\nThe table below shows common use cases for this method. You can click on a use case name to load sample parameter values in the APIs Explorer. Or you can see code samples for a use case in the fullscreen APIs Explorer by clicking on the code icon below a use case name. In the fullscreen UI, you can update parameter and property values and the code samples will dynamically update to reflect the values you enter. \nThis method has one common use case, which is described below. The buttons below the description populate the APIs Explorer with sample values or open the fullscreen APIs Explorer to show code samples that use those values. The code samples also dynamically update if you change the values.\n\n\u003cbr /\u003e\n\nRequest\n-------\n\n### HTTP request\n\n```\nGET https://www.googleapis.com/youtube/v3/comments\n```\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 specifies a comma-separated list of one or more `comment` resource properties that the API response will include. The following list contains the `part` names that you can include in the parameter value: - `id` - `snippet` |\n| **Filters (specify exactly one of the following parameters)** |||\n| `id` | `string` The **id** parameter specifies a comma-separated list of comment IDs for the resources that are being retrieved. In a `comment` resource, the `id` property specifies the comment's ID. |\n| `parentId` | `string` The **parentId** parameter specifies the ID of the comment for which replies should be retrieved. **Note:** YouTube currently supports replies only for top-level comments. However, replies to replies may be supported in the future. |\n| **Optional parameters** |||\n| `maxResults` | `unsigned integer` The **maxResults** parameter specifies the maximum number of items that should be returned in the result set. **Note:** This parameter is not supported for use in conjunction with the [id](#id) parameter. Acceptable values are `1` to `100`, inclusive. The default value is `20`. |\n| `pageToken` | `string` The **pageToken** parameter identifies a specific page in the result set that should be returned. In an API response, the `nextPageToken` property identifies the next page of the result that can be retrieved. **Note:** This parameter is not supported for use in conjunction with the [id](#id) parameter. |\n| `textFormat` | `string` This parameter indicates whether the API should return comments formatted as HTML or as plain text. The default value is `html`. Acceptable values are: - **html** -- Returns the comments in HTML format. This is the default value. - **plainText** -- Returns the comments in plain text format. |\n\n### Request body\n\nDo not provide a request body when calling this method.\n\nResponse\n--------\n\nIf successful, this method returns a response body with the following structure: \n\n```objective-c\n{\n \"kind\": \"youtube#commentListResponse\",\n \"etag\": etag,\n \"nextPageToken\": string,\n \"pageInfo\": {\n \"totalResults\": integer,\n \"resultsPerPage\": integer\n },\n \"items\": [\n comment Resource\n ]\n}\n```\n\n### Properties\n\nThe following table defines the properties that appear in this resource:\n\n| Properties ||\n|---------------------------|----------------------------------------------------------------------------------------------------------------------------|\n| `kind` | `string` Identifies the API resource's type. The value will be `youtube#commentListResponse`. |\n| `etag` | `etag` The Etag of this resource. |\n| `nextPageToken` | `string` The token that can be used as the value of the `pageToken` parameter to retrieve the next page in the result set. |\n| `pageInfo` | `object` The `pageInfo` object encapsulates paging information for the result set. |\n| pageInfo.`totalResults` | `integer` The total number of results in the result set. |\n| pageInfo.`resultsPerPage` | `integer` The number of results included in the API response. |\n| `items[]` | `list` A list of comments that match the request criteria. |\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)` | `operationNotSupported` | The id filter is only compatible with comments based on Google+. |\n| `forbidden (403)` | `forbidden` | One or more of the requested comments cannot be retrieved due to insufficient permissions. The request might not be properly authorized. |\n| `notFound (404)` | `commentNotFound` | One or more of the specified comments cannot be found. Check the values of the request's [id](/youtube/v3/docs/comments/list#id) and [parentId](/youtube/v3/docs/comments/list#parentId) parameters to ensure that they are correct. |\n\nTry it!\n-------\n\nUse the APIs Explorer to call this API and see the API request and response."]]