> ## 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.

# Reddit API

> Các tùy chọn để đăng bài bằng Reddit API

export const HeaderAPI = ({noProfileKey, profileKeyRequired}) => <>
    <ParamField header="Authorization" type="string" required>
      <a href="/apis/overview#authorization">API Key</a> of the Primary Profile.
      <br />
      <br />
      Format: <code>Authorization: Bearer API_KEY</code>
    </ParamField>
    {!noProfileKey && (profileKeyRequired ? <ParamField header="Profile-Key" type="string" required>
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField> : <ParamField header="Profile-Key" type="string">
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField>)}
  </>;

## Đăng bài lên Reddit

Sau đây là các tham số body bắt buộc để đăng bài bằng Reddit API. Vui lòng đảm bảo subreddit cho phép đăng bài tự động.
Vui lòng xem [Reddit Media Guidelines](/media-guidelines/reddit) và [Reddit Authorization](/dashboard/connect-social-accounts/reddit) để biết thêm thông tin.

```json Reddit Post theme={"system"}
{
  "post": "Reddit post", // empty string is allowed
  "platforms": ["reddit"], // required
  "redditOptions": {
    "title": "Reddit Post Title", // required
    "subreddit": "test", // required (no "/r/" needed)
    "link": "https://www.website.com" // optional: post a link
  }
}
```

<ul class="custom-bullets">
  <li>`title` (bắt buộc): Tiêu đề của bài đăng trên Reddit.</li>

  <li>
    `subreddit` (bắt buộc): Subreddit để gửi bài đăng. Vui lòng đảm bảo tuân theo các quy tắc
    đăng bài của subreddit. Một subreddit tốt để dùng cho việc kiểm thử là */r/test/* và có thể xem tại:
    [https://www.reddit.com/r/test/](https://www.reddit.com/r/test/)
  </li>

  <li>
    `link` (tùy chọn): Nếu đăng lên Reddit và bạn muốn đăng một liên kết thay vì văn bản lên
    subreddit. Trong khi nội dung văn bản tham số `post` vẫn bắt buộc, nó không được bao gồm trong bài đăng
    vì các liên kết Reddit không thể có phần nội dung văn bản.
  </li>
</ul>

<Warning>
  Luôn kiểm tra các quy tắc của subreddit trước khi đăng bài. Một số subreddit có ngưỡng karma,
  yêu cầu là thành viên trong một khoảng thời gian, giới hạn tần suất đăng bài, không cho phép hình ảnh, hoặc
  yêu cầu thêm flair. Ngoài ra, hầu hết các subreddit đều có quy tắc cụ thể về spam và tự quảng bá.
  Không tuân theo các quy tắc này có thể dẫn đến việc bị cấm bởi subreddit hoặc Reddit.
</Warning>

## Đăng hình ảnh lên Reddit

Đăng hình ảnh lên Reddit bằng cách bao gồm URL hình ảnh trong tham số `mediaUrl` hoặc tham số `link` của `redditOptions`. Hình ảnh được đăng dưới dạng `link` sẽ giải quyết thành hình ảnh đầy đủ.

Nội dung văn bản tham số `post` bị bỏ qua, nhưng vẫn bắt buộc để gửi bài đăng thành công. Reddit hạn chế đăng hình ảnh và văn bản cùng nhau đối với trình chỉnh sửa "fancy pants" trực tuyến của họ. Điều này có nghĩa là chỉ có thể đăng hình ảnh hoặc văn bản, nhưng không thể cả hai cùng lúc.

```json Reddit Post with Image theme={"system"}
{
  "post": "Reddit post", // required, but not added to the post
  "platforms": ["reddit"], // required
  "mediaUrls": "https://my-media-url.com",
  "redditOptions": {
    "title": "Reddit Post Title", // required
    "subreddit": "test" // required (no "/r/" needed)
  }
}
```

## Thêm Reddit Flair

Một số subreddit yêu cầu flair. Các moderator của subreddit đã định nghĩa trước flair và mỗi flair có một ID duy nhất. Trong bài đăng Reddit lên Ayrshare, hãy thêm flair ID và một flair text tùy chọn nếu văn bản có thể được ghi đè.

```json Reddit Post with Flair theme={"system"}
{
  "redditOptions": {
    "flairId": "jM8nH92enjswas", // Id of the flair
    "flairText": "My New Flair text" // Override the flair text if allowed by flair
  }
}
```

Bạn có thể tìm flair ID của một subreddit bằng cách gọi endpoint [/post/redditFlair](/apis/utils/reddit-get-flair).

## Kiểm tra một subreddit có tồn tại hay không

Kiểm tra xem một subreddit có tồn tại hay không bằng [endpoint /validate](/apis/validate/check-subreddit).

## Thêm định dạng văn bản phong phú cho bài đăng Reddit

Nếu bạn muốn thêm văn bản đậm, nghiêng, hoặc superscript vào bài đăng Reddit, hãy sử dụng [Reddit-flavored Markdown](https://www.reddit.com/wiki/markdown#wiki_new_reddit-flavored_markdown).

```json Reddit Post with Rich Text theme={"system"}
{
  "post": "For example, this can be *italic* or **bold** or ^super ",
  "platforms": ["reddit"],
  "redditOptions": {
    "title": "Rich Text Post",
    "subreddit": "test"
  }
}
```

## Nhắc tên (Mention) trên Reddit

Nhắc tên một người dùng Reddit khác hoặc một subreddit.

<ul class="custom-bullets">
  <li>Nhắc tên một người dùng Reddit bằng cách thêm `@subreddit` hoặc `u/username` vào nội dung bài đăng.</li>
  <li>Nhắc tên một subreddit bằng cách thêm `r/subreddit` vào nội dung bài đăng.</li>
</ul>

Ví dụ:

```json Reddit Post with Mention theme={"system"}
{
  "post": "The best Reddit post ever for user @ayrshare and subreddit r/SiliconValleyHBO",
  "platforms": ["reddit"]
}
```

<Warning>
  Vui lòng xem lại [các quy tắc quan trọng](/testing/post-verification#mentions) về nhắc tên.
</Warning>

## Giới hạn ký tự

Vui lòng xem [Giới hạn ký tự Reddit](/help-center/technical-support/character_limits#reddit-character-limits) để biết thêm thông tin.

## Endpoint bổ sung

<Card title="Get Reddit Flair" icon="code" href="/apis/utils/reddit-get-flair" horizontal />
