VI | EN
Message us on Messenger
Developer resources

Post attachments — Facebook API

Post Attachments · call it through Quantri360 with one API key for your own accounts / assets that you connected and authorized — 360 handles request signing and refreshing the authorization you granted.

Post Attachments

GET/{version}/{post_id}/attachmentsVia 360: GET https://partner.quantri360.com/v1/facebook/{version}/{post_id}/attachments
Coming soon. This API already runs in production through 360 and pricing is being finalised — you can read the docs and prepare your integration now.
Description

Phần đính kèm của bài viết: ảnh, album nhiều ảnh, video, link — loại, link xem, ảnh xem trước, id đối tượng đích. Dùng lấy ảnh / video của bài để hiển thị hoặc nối với sản phẩm.

  • Không có phân trang ở cấp này; album dài dùng subattachments.limit(N).
  • Link ảnh / video trong media hết hạn sau một thời gian.

Request

Endpoint

GET https://partner.quantri360.com/v1/facebook/{version}/{post_id}/attachments

Authentication & shop

NameInTypeSampleDescription
AuthorizationheaderheaderBearer q360_live_ab12cd34_…Khóa API của brand (tạo ở mục API key). Bắt buộc với mọi request. Brand suy từ key — không truyền mã brand.
platform_shop_idquerystringact_123456789 hoặc 1234567890Tài sản Facebook brand đã nối với 360: tài khoản quảng cáo (act_<id> hoặc <id>), Page id hoặc Pixel id — lấy ở GET /v1/platforms. Có thể bỏ khi đường dẫn đã chứa act_<id> / page id của brand.

Request parameters

NameInTypeRequiredSampleDescription
versionpathstringYesv25.0
post_idpathstringYes303881193849929_1128982042970549Id bài <page_id>_<post_id>.
fieldsquerystringNotype,media_type,url,title,description,media,target,subattachmentsTrường cần lấy. Không gửi = đủ trường mặc định. Album nhiều ảnh: subattachments.limit(N).

Request examples

curl -s "https://partner.quantri360.com/v1/facebook/v25.0/303881193849929_1128982042970549/attachments?fields=type%2Cmedia_type%2Curl%2Cdescription%2Cmedia%2Ctarget" \
  -H "Authorization: Bearer $KEY"
Python
import requests

KEY = "q360_live_..."  # khóa API của brand
r = requests.get(
    "https://partner.quantri360.com/v1/facebook/v25.0/303881193849929_1128982042970549/attachments",
    params={
        "fields": "type,media_type,url,description,media,target"
    },
    headers={"Authorization": f"Bearer {KEY}"},
    timeout=60,
)
print(r.status_code)
print(r.json())
Node.js
const KEY = 'q360_live_...'; // khóa API của brand
const url = new URL('https://partner.quantri360.com/v1/facebook/v25.0/303881193849929_1128982042970549/attachments');
for (const [k, v] of Object.entries({"fields":"type,media_type,url,description,media,target"})) url.searchParams.set(k, typeof v === 'object' ? JSON.stringify(v) : String(v));
const r = await fetch(url, {
  method: 'GET',
  headers: { Authorization: `Bearer ${KEY}` },
});
console.log(r.status, await r.json());
PHP
<?php
$key = 'q360_live_...'; // khóa API của brand
$url = 'https://partner.quantri360.com/v1/facebook/v25.0/303881193849929_1128982042970549/attachments' . '?' . http_build_query(['fields' => 'type,media_type,url,description,media,target']);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $key]);
$res = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status, "\n", $res;

Response

Response fields (as returned by Facebook)

NameTypeSampleDescription
dataobject[]Thường 1 phần tử.
typestringphoto`photo` · `album` · `video_inline` · `share` (link) · `native_templates` …
media_typestringphoto`photo` · `video` · `link` · `album`.
urlstringLink xem trên Facebook.
title / descriptionstringTiêu đề / mô tả (description thường = nội dung bài).
mediaobject`{image: {src, width, height}}`; video thêm `source` (link tệp video, có hạn).
targetobject`{id, url}` — id ảnh / video đích (dùng cho /comments, /video_insights).
subattachmentsobjectAlbum: `{data: [ {type, media, target, url}, … ]}`.

Response sample

{
  "data": [
    {
      "type": "photo",
      "media_type": "photo",
      "url": "https://www.facebook.com/photo.php?fbid=1128981969637223&set=a.258026…&type=3",
      "description": "NATURE INSPIRES | HÉ LỘ CẢM HỨNG MÙA ĐÔNG…",
      "media": {
        "image": {
          "height": 898,
          "src": "https://scontent.fsgn24-2.fna.fbcdn.net/v/t39.30808-6/…",
          "width": 720
        }
      },
      "target": {
        "id": "1128981969637223",
        "url": "https://www.facebook.com/photo.php?fbid=1128981969637223&set=a.258026…&type=3"
      }
    }
  ]
}

Get started

  1. Sign up for Partner
  2. Enable a data type of the Trang & Messenger group on the platform page
  3. Create an API key (tick the Facebook channel)
  4. Call it as in the examples above