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

# 通过 URL 或帖子 ID 获取帖子详情

> 通过 URL 或帖子 ID 获取帖子详情。如果两个参数都提供，将优先使用帖子 ID。

<div className="inline-flex items-center gap-2 px-4 py-2 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg">
  <span className="text-base">🪙</span>
  <span className="text-sm font-medium text-yellow-900 dark:text-yellow-100"><span className="font-semibold">4 credits</span><span className="text-yellow-700 dark:text-yellow-300 ml-1">每次请求</span></span>
</div>

## 复制给 AI

<div className="my-6 rounded-xl border border-gray-200 bg-gray-50 p-5 dark:border-gray-800 dark:bg-gray-900/40">
  <div className="min-w-0">
    <p className="text-base font-semibold text-gray-900 dark:text-gray-100">🤖 为什么还要自己写代码？</p>
    <p className="mt-1 text-sm text-gray-700 dark:text-gray-300">让 AI 来处理重复工作。点击按钮即可复制一段整理好的提示词，用于 ChatGPT、Claude 或你常用的 AI 助手。</p>
  </div>

  <div className="mt-4">
    <button
      type="button"
      className="inline-flex items-center gap-2 rounded-md border border-emerald-300 bg-emerald-50 px-3 py-2 text-sm font-medium text-emerald-800 hover:bg-emerald-100 dark:border-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-100 dark:hover:bg-emerald-900/50"
      onClick={() => navigator.clipboard.writeText(`我需要调用下面的 KeyAPI 接口，请根据提供的接口信息生成一份完整、可直接运行的 Python 示例代码。

## 接口信息

Endpoint: GET https://api.keyapi.ai/v1/facebook/post_details
摘要: 通过 URL 或帖子 ID 获取帖子详情

必需请求头:
- Authorization: Bearer <YOUR_API_KEY>

参数:
- post_id (可选): Facebook 帖子 ID. 示例: pfbid04KTWEM9Rri6Wg3oLRBF5FUUvfPebQ6ZJRwVivymc8e8KWvy3RsnpUXyppjEZqkwZl
- post_url (可选): Facebook 帖子 URL。请提供 \`post_id\` 或 \`post_url\` 其中之一.

## 代码要求

- 使用 Python \`requests\` 库
- 提供完整、可直接运行的示例
- 处理 HTTP 请求异常、超时以及非 2xx 响应
- 处理 JSON 解析异常
- 示例参数优先使用接口信息中提供的 Example
- 保持代码简单，避免不必要的封装和复杂设计`)}
    >
      <span>✨</span>
      <span>复制给 AI</span>
    </button>
  </div>
</div>


## OpenAPI

````yaml /zh/facebook.zh.openapi.json get /v1/facebook/post_details
openapi: 3.0.1
info:
  title: KeyAPI Facebook API 中文文档
  description: KeyAPI Facebook API 的中文参考文档，包含接口用途、参数说明、响应状态和示例结构。
  version: 1.0.0
servers:
  - url: https://api.keyapi.ai
    description: Production-KeyAPI
security:
  - JWT Bearer: []
tags:
  - name: 公共主页
  - name: 个人主页
  - name: 群组
  - name: 帖子与评论
  - name: 广告库
  - name: 活动
  - name: 搜索
  - name: Marketplace
  - name: 游戏
paths:
  /v1/facebook/post_details:
    get:
      tags:
        - 帖子与评论
      summary: 通过 URL 或帖子 ID 获取帖子详情
      description: 通过 URL 或帖子 ID 获取帖子详情。如果两个参数都提供，将优先使用帖子 ID。
      parameters:
        - name: post_id
          in: query
          description: Facebook 帖子 ID。
          required: false
          example: >-
            pfbid04KTWEM9Rri6Wg3oLRBF5FUUvfPebQ6ZJRwVivymc8e8KWvy3RsnpUXyppjEZqkwZl
          schema:
            type: string
            example: >-
              pfbid04KTWEM9Rri6Wg3oLRBF5FUUvfPebQ6ZJRwVivymc8e8KWvy3RsnpUXyppjEZqkwZl
        - name: post_url
          in: query
          description: Facebook 帖子 URL。请提供 `post_id` 或 `post_url` 其中之一。
          required: false
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
              example:
                code: 0
                message: success
                data:
                  results:
                    post_id: '1017566160415404'
                    type: post
                    url: >-
                      https://www.facebook.com/facebook/posts/pfbid04LGZncNDK9chi72WkGExZyxmsxhbczdieGpVPJT4Hp2izvkEeWNxeWacs7fu1SGxl
                    message: Nothing works when your ponytail is too tight.
                    message_rich: Nothing works when your ponytail is too tight.
                    timestamp: 1731700941
                    comments_count: 3117
                    reactions_count: 10000
                    reshare_count: 1745
                    reactions:
                      angry: 19
                      care: 48
                      haha: 4276
                      like: 5329
                      love: 258
                      sad: 10
                      wow: 60
                    author:
                      id: '100064860875397'
                      name: Facebook
                      url: https://www.facebook.com/facebook
                      profile_picture_url: >-
                        https://scontent.ffcm1-2.fna.fbcdn.net/v/t39.30808-1/380700650_10162533193146729_2379134611963304810_n.jpg?stp=cp0_dst-jpg_tt6&cstp=mx2048x2048&ctp=s80x80&_nc_cat=1&ccb=1-7&_nc_sid=2d3e12&_nc_ohc=v825A_xemiwQ7kNvwHS9chZ&_nc_oc=AdoB8Wx9Knq8G8_QHEK-A-4UnKvF5cWLS2Y2LQxXIaFwhUb628R1tuFoiRxiJe_MyUs&_nc_zt=24&_nc_ht=scontent.ffcm1-2.fna&_nc_gid=eYGCK7Ajif54qPTodleSmQ&_nc_ss=7d289&oh=00_AQIEK16F6VKwmSUDVxWwtQ7pnzAauQItrnv67AQAdhMFbg&oe=6AB8080E
                      delegate_page_id: '20531316728'
                    authors:
                      - id: '100064860875397'
                        name: Facebook
                        url: https://www.facebook.com/facebook
                        profile_picture_url: >-
                          https://scontent.ffcm1-2.fna.fbcdn.net/v/t39.30808-1/380700650_10162533193146729_2379134611963304810_n.jpg?stp=cp0_dst-jpg_tt6&cstp=mx2048x2048&ctp=s80x80&_nc_cat=1&ccb=1-7&_nc_sid=2d3e12&_nc_ohc=v825A_xemiwQ7kNvwHS9chZ&_nc_oc=AdoB8Wx9Knq8G8_QHEK-A-4UnKvF5cWLS2Y2LQxXIaFwhUb628R1tuFoiRxiJe_MyUs&_nc_zt=24&_nc_ht=scontent.ffcm1-2.fna&_nc_gid=eYGCK7Ajif54qPTodleSmQ&_nc_ss=7d289&oh=00_AQIEK16F6VKwmSUDVxWwtQ7pnzAauQItrnv67AQAdhMFbg&oe=6AB8080E
                        delegate_page_id: '20531316728'
                    author_title: null
                    image: null
                    video: null
                    video_view_count: null
                    album_preview: null
                    video_files: null
                    video_thumbnail: null
                    external_url: null
                    attached_event: null
                    attached_group: null
                    attached_post: null
                    attached_post_url: null
                    text_format_metadata: null
                    comments_id: '1017566160415404'
                    shares_id: '1017566160415404'
                    associated_group_id: null
                    associated_group: null
                    images_count: null
                    top_comments:
                      - type: top_comment
                        id: >-
                          Y29tbWVudDoxMDE3NTY2MTYwNDE1NDA0XzE4ODU3ODQxMjIxOTQ0MDQ=
                        legacy_fb_id: '1885784122194404'
                        text: Loosen the ponytail and enjoy life!☺️
                        author:
                          id: '100051456016380'
                          name: Bigyan Mudbari
                          url: https://www.facebook.com/100051456016380
                          gender: null
                          profile_image_url: null
                        created_time: 1731701033
                      - type: top_comment
                        id: >-
                          Y29tbWVudDoxMDE3NTY2MTYwNDE1NDA0XzE1NjkxNzU4MzM3OTkwNDQ=
                        legacy_fb_id: '1569175833799044'
                        text: Honestly i cant breath with tight ponytail
                        author:
                          id: '100004257521394'
                          name: Winfred Bauer
                          url: https://www.facebook.com/100004257521394
                          gender: null
                          profile_image_url: null
                        created_time: 1731701783
                      - type: top_comment
                        id: >-
                          Y29tbWVudDoxMDE3NTY2MTYwNDE1NDA0XzEwODE0Mzk5NzcwMjQ3NDI=
                        legacy_fb_id: '1081439977024742'
                        text: Loosen the ponytail and enjoy life!☺️
                        author:
                          id: '100044169247872'
                          name: Kurian Presenter
                          url: https://www.facebook.com/100044169247872
                          gender: null
                          profile_image_url: null
                        created_time: 1731701883
                      - type: top_comment
                        id: >-
                          Y29tbWVudDoxMDE3NTY2MTYwNDE1NDA0XzEwNzMxNTM3OTA3NjI5NDk=
                        legacy_fb_id: '1073153790762949'
                        text: Headache and everything.👍🏻🤣
                        author:
                          id: >-
                            pfbid0Wjirrd1oqqijsiDo8GPsogJzyRtma5JLd3zvhbDEzNGymX7cXgVbHdXavpmN8bEbl
                          name: Denisse Cafengiu
                          url: >-
                            https://www.facebook.com/pfbid0Wjirrd1oqqijsiDo8GPsogJzyRtma5JLd3zvhbDEzNGymX7cXgVbHdXavpmN8bEbl
                          gender: null
                          profile_image_url: null
                        created_time: 1731701961
                      - type: top_comment
                        id: >-
                          Y29tbWVudDoxMDE3NTY2MTYwNDE1NDA0XzIyMDA1OTAwNTcwMDI4NDY=
                        legacy_fb_id: '2200590057002846'
                        text: Nothing works if my ponytail is too LOOSE
                        author:
                          id: >-
                            pfbid0yUqJq7WqUPy2tVe8qbrQVKSuF3DrV6u3aQ2FyScUyifhk2J91kYvTnycLd6Qjwmnl
                          name: Cara Stone
                          url: >-
                            https://www.facebook.com/pfbid0yUqJq7WqUPy2tVe8qbrQVKSuF3DrV6u3aQ2FyScUyifhk2J91kYvTnycLd6Qjwmnl
                          gender: null
                          profile_image_url: null
                        created_time: 1731702332
                requestId: 6ba4a46f-74bb-4584-9728-e06c901ba8d7
          headers: {}
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '402':
          $ref: '#/components/responses/402'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
      deprecated: false
      security:
        - JWT Bearer: []
components:
  responses:
    '400':
      description: Bad Request
      content:
        application/json:
          schema:
            type: object
            example:
              code: 400
              data: null
              message: 'Missing required parameter: handle'
    '401':
      description: Unauthorized
      content:
        application/json:
          schema:
            type: object
            example:
              code: 401
              data: null
              message: apiKey is null
    '402':
      description: Payment Required
      content:
        application/json:
          schema:
            type: object
            example:
              code: 402
              data: null
              message: apiKey quota is not enough
    '429':
      description: Too Many Requests
      content:
        application/json:
          schema:
            type: object
            example:
              code: 429
              data: null
              message: qps limit exceeded
    '500':
      description: Internal Server Error
      content:
        application/json:
          schema:
            type: object
            example:
              code: 500
              data: null
              message: Internal server error
  securitySchemes:
    JWT Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |-
        接口鉴权凭证。请在请求 Header 中传入 `Authorization: Bearer <YOUR_API_KEY>`。
        可在 [Dashboard](https://keyapi.ai/app/dashboard) 获取你的 API Key。

````