> ## 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 概述

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

export const PlansAvailable = ({plans = [], maxPackRequired}) => {
  let displayPlans = plans;
  if (plans && plans.length === 1) {
    const lowerCasePlan = plans[0].toLowerCase();
    if (lowerCasePlan === "business") {
      displayPlans = ["Launch", "Business", "Enterprise"];
    } else if (lowerCasePlan === "premium") {
      displayPlans = ["Premium", "Launch", "Business", "Enterprise"];
    }
  }
  return <Note>
Available on {displayPlans.length === 1 ? "the " : ""}
{displayPlans.join(", ").replace(/\b\w/g, l => l.toUpperCase())}{" "}
{displayPlans.length > 1 ? "plans" : "plan"}.

{maxPackRequired && <span onClick={() => window.open('https://www.ayrshare.com/docs/additional/maxpack', '_self')} className="flex items-center mt-2 cursor-pointer">
 <span className="px-1.5 py-0.5 rounded text-sm" style={{
    backgroundColor: '#C264B6',
    color: 'white',
    fontSize: '12px'
  }}>
   Max Pack required
 </span>
</span>}
</Note>;
};

<PlansAvailable plans={["premium"]} maxPackRequired={false} />

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

## 评论 ID 类型

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

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

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

例如：

<Steps>
  <Step title="发布一条帖子">
    使用 [/post](/apis/post/post) 端点通过 Ayrshare 发布一条帖子，该端点可以在一次调用中将帖子发送到多个社交网络。

    返回结果中的顶层字段是 [Ayrshare 帖子 ID](/apis/overview#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
    }
    ```
  </Step>

  <Step title="发布一条评论">
    使用 [/comments](/apis/comments/post-comment) 端点，并附上 Ayrshare 帖子 ID 来发布评论。
    该评论将自动发布到原始帖子所发布的每个社交网络。
    例如，如果你将帖子发布到 Facebook 和 Instagram，评论将出现在这两个平台上。

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

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

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

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

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

<Note>
  如果帖子是通过 Ayrshare 发布的，请使用 [Ayrshare 帖子 ID](/apis/comments/overview#comments-with-ayrshare-post-id)。
</Note>

例如：

<Steps>
  <Step title="获取帖子历史">
    首先，通过[获取全部帖子历史端点](/apis/history/history-platform)获取在 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` 也会在[帖子端点](/apis/post/post)的 `postIds` 字段中返回。</Note>
  </Step>

  <Step title="获取某条帖子上的评论">
    使用返回的 `id` 来[获取所有评论](/apis/comments/get-comments)，将 `searchPlatformId` 设置为 `true`，并将 `platform` 设置为 `instagram`，从而获取某个 Instagram 帖子的评论。

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

  <Step title="使用评论 ID 获取评论详情">
    上一步返回的 JSON 中每条评论都会有一个 `commentId`，它就是[社交评论 ID](/apis/overview#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"
            }
        ]
    }

    ```
  </Step>
</Steps>

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

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

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

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

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

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

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

## 禁用评论

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

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

## 平台限制

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

```
```
