> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 评论 API 概述

> 对社交帖子发布、回复、获取和删除评论

评论端点允许你的用户对其帖子进行发表、回复、获取和删除评论。
评论 ID 共有四种类型：Ayrshare 帖子 ID、社交帖子 ID、Ayrshare 评论 ID 和社交评论 ID。
它们各自用于不同的用途。

如需实时接收已关联 Threads 帖子上的新回复，请注册 [`comments` webhook](https://www.ayrshare.com/docs/apis/webhooks/actions#comments-action)。

## 评论 ID 类型

### 通过 Ayrshare 帖子 ID 管理评论

典型的流程是：当你通过 Ayrshare 发布帖子时，会获得 Ayrshare 帖子 ID。
然后你可以使用此 [Ayrshare 帖子 ID](https://www.ayrshare.com/docs/apis/overview.md#ayrshare-post-id) 来管理该帖子上的评论。

支持的平台：Bluesky、Facebook Pages、Instagram、LinkedIn、Reddit、Threads、TikTok、Twitter 和 YouTube。

例如：

**1. 发布一条帖子**

使用 [/post](https://www.ayrshare.com/docs/apis/post/post.md) 端点通过 Ayrshare 发布一条帖子，该端点可以在一次调用中将帖子发送到多个社交网络。

返回结果中的顶层字段是 [Ayrshare 帖子 ID](https://www.ayrshare.com/docs/apis/overview.md#ayrshare-post-id)。

```json {12} theme={"system"}
{
    "status": "success",
    "errors": [],
    "postIds": [
    {
        "status": "success",
        "id": "106638148652329_591370753547555",
        "postUrl": "https://www.facebook.com/106638148652329/posts/591370753547555",
        "platform": "facebook"
    }
    ],
    "id": "E4UdUr1yRbvI7qqCSlaq", // Ayrshare Post ID
    "refId": "9abf1426d6ce9122ef11c72bd62e59807c5cc055",
    "post": "What an amazing day",
    "validate": true
}
```

**2. 发布一条评论**

使用 [/comments](https://www.ayrshare.com/docs/apis/comments/post-comment.md) 端点，并附上 Ayrshare 帖子 ID 来发布评论。
该评论将自动发布到原始帖子所发布的每个社交网络。
例如，如果你将帖子发布到 Facebook 和 Instagram，评论将出现在这两个平台上。

```http theme={"system"}
POST https://api.ayrshare.com/api/comments/:id
```

**3. 获取评论**

使用 [/comments](https://www.ayrshare.com/docs/apis/comments/get-comments.md) 端点，并附上 Ayrshare 帖子 ID 来获取该帖子的评论。
这将返回该帖子所发布的每个社交网络上的所有评论。
例如，如果你发布到 Facebook 和 Instagram，你将获得来自这两个平台的评论。

```http theme={"system"}
GET https://api.ayrshare.com/api/comments/:id
```

### 通过社交帖子 ID 管理评论

有时你可能希望管理并非通过 Ayrshare 发布的帖子的评论。
此时你可以使用[社交帖子 ID](https://www.ayrshare.com/docs/apis/overview.md#social-post-id)，即社交网络分配的帖子 ID。

> [!NOTE]
>
> 在 Facebook、Instagram 和 TikTok 上，帖子必须属于你自己已关联的账户或主页，例如你直接在 Instagram 应用中发布的帖子。即使使用社交帖子 ID 或社交评论 ID，这些平台也不允许你获取或回复其他用户帖子上的评论。在 Bluesky、LinkedIn、X 和 YouTube 上，能否处理其他用户帖子上的评论取决于该网络的规则以及该帖子的设置。请参阅[在其他用户的社交帖子上评论](https://www.ayrshare.com/docs/help-center/technical-support/commenting-on-another-user-post.md)。

> [!NOTE]
>
> 如果帖子是通过 Ayrshare 发布的，请使用 [Ayrshare 帖子 ID](https://www.ayrshare.com/docs/apis/comments/overview.md#comments-with-ayrshare-post-id)。

例如：

**1. 获取帖子历史**

首先，通过[获取全部帖子历史端点](https://www.ayrshare.com/docs/apis/history/history-platform.md)获取在 Ayrshare 外部发布的 Instagram 帖子。

该端点返回一个帖子列表，其中包含帖子的社交 `id`。

```json {13} theme={"system"}
{
    "status": "success",
    "posts": [
        {
            "mediaUrl": "https://scontent.cdninstagram.com/v/t51.2885-15/7531.jpg",
            "permalink": "https://www.instagram.com/p/B5OBT3ygpfg/",
            "commentsCount": 0,
            "created": "2022-05-20T17:26:03Z",
            "likeCount": 0,
            "mediaProductType": "FEED",
            "mediaType": "IMAGE",
            "username": "thegoodone",
            "id": "17833140557332933", // Instagram Social Post ID
            "thumbnailUrl": "https://scontent-lga3-2.cdninstagram.com/v/t51..jpg",
            "post": "The #Mandalorian is on tonight instead of Friday",
            "postUrl": "https://www.instagram.com/p/B5OBT3ygpfg/"
        },
    ]
}
```

> [!NOTE]
>
> 社交帖子 `id` 也会在[帖子端点](https://www.ayrshare.com/docs/apis/post/post.md)的 `postIds` 字段中返回。

**2. 获取某条帖子上的评论**

使用返回的 `id` 来[获取所有评论](https://www.ayrshare.com/docs/apis/comments/get-comments.md)，将 `searchPlatformId` 设置为 `true`，并将 `platform` 设置为 `instagram`，从而获取某个 Instagram 帖子的评论。

```http theme={"system"}
GET https://api.ayrshare.com/api/comments/17833140557332933?platform=instagram&searchPlatformId=true
```

**3. 使用评论 ID 获取评论详情**

上一步返回的 JSON 中每条评论都会有一个 `commentId`，它就是[社交评论 ID](https://www.ayrshare.com/docs/apis/overview.md#social-comment-id)。

```json {5} theme={"system"}
{
    "instagram": [
        {
            "comment": "What an amazing comment",
            "commentId": "17969247335804735", // Social Comment ID
            "created": "2024-11-26T11:49:00Z",
            "from": {
            "id": "103038435208332",
            "username": "john_smith"
            },
            "hidden": false,
            "likeCount": 3,
            "platform": "instagram",
            "postId": "18231730279304333",
            "username": "john_smith"
        }
    ]
}

```

### 通过 Ayrshare 评论 ID 管理评论

使用 [Ayrshare 评论 ID](https://www.ayrshare.com/docs/apis/overview.md#ayrshare-comment-id) 来管理通过 Ayrshare 发布的帖子上的评论。
Ayrshare 评论 ID 是 Ayrshare 分配的评论 ID，可在[发布评论](https://www.ayrshare.com/docs/apis/comments/post-comment.md)时的响应中的 `commentId` 字段中找到。

这通常用于获取通过 Ayrshare 发布的特定评论的详细信息。

### 通过社交评论 ID 管理评论

使用[社交评论 ID](https://www.ayrshare.com/docs/apis/overview.md#social-comment-id) 来管理并非通过 Ayrshare 发布的帖子上的评论。
社交评论 ID 是社交网络的评论 ID，而不是 Ayrshare ID，可在[获取评论](https://www.ayrshare.com/docs/apis/comments/get-comments.md)时的响应中的 `commentId` 字段中找到。

```http theme={"system"}
GET https://api.ayrshare.com/api/comments/17969247335804735?platform=instagram&searchPlatformId=true&commentId=true
```

这通常用于获取在 Ayrshare 外部发布的特定评论的详细信息，例如 LinkedIn 对评论的回复。

## 禁用评论

在发布帖子时，你可以使用 [/post 端点](https://www.ayrshare.com/docs/apis/post/post.md)中的 `disableComments` 字段来禁用评论。评论仅会在 Instagram、LinkedIn 和 TikTok 上被禁用。

你也可以使用[更新帖子](https://www.ayrshare.com/docs/apis/post/update-post.md)端点及 `disableComments` 字段，对已发布的帖子启用或禁用评论。

## 平台限制

> [!NOTE]
>
> **TikTok — `DELETE /comments` 仅限自己发表的评论。** 在 TikTok 上，[`DELETE /comments`](https://www.ayrshare.com/docs/apis/comments/delete-comments) 仅在评论由已认证的 TikTok 账户自身撰写（即你自己的回复）时才会成功。尝试删除其他用户撰写的评论会返回 Ayrshare `code: 328`。若要审核你自己 TikTok 视频中的第三方评论，请联系支持团队，以便我们确认你所关联账户类型可用的功能。

```
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.