VI
Nhắn Messenger
API Facebook
Dành cho developer

Tải video quảng cáo lên (theo file_url) — API Facebook

Upload Ad Video · gọi qua Quantri360 bằng một API key cho chính tài khoản / tài sản bạn đã kết nối và ủy quyền — 360 lo việc ký request và làm mới phiên đăng nhập bạn đã cấp.

Upload Ad Video

POST/{version}/act_{account_id}/advideosGọi qua 360: POST https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/advideos
Endpoint ghi — thay đổi dữ liệu trên Facebook. Key phải được tạo với tick "Cho phép gọi API ghi", nếu không sẽ nhận 403 write_not_allowed. Mỗi lần gọi được ghi nhật ký.
Mô tả API

Tải video vào thư viện của tài khoản quảng cáo từ một URL công khai, để dùng khi tạo nội dung quảng cáo video. ENDPOINT GHI.

  • Là API GHI; key cần quyền ghi (can_write) và gói mở module Quảng cáo, mỗi lần gọi được 360 ghi nhật ký.
  • Video xử lý sau khi tải; chỉ dùng được khi GET /{version}/{object_id}?fields=status báo sẵn sàng. URL không tải được → lỗi 389.
  • Chưa nhận tải tệp trực tiếp / theo phần qua 360 — chỉ file_url. Gỡ video khỏi tài khoản chưa mở qua 360.

Request

Địa chỉ

POST https://partner.quantri360.com/v1/facebook/{version}/act_{account_id}/advideos

Xác thực & gian hàng

TênVị tríKiểuMẫuMô tả
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.

Tham số request

TênVị tríKiểuBắt buộcMẫuMô tả
versionpathstringCóv25.0
account_idpathstringCó1000000000000001Id tài khoản quảng cáo đã nối (không gồm tiền tố act_).
file_urlbodystringCóhttps://example.com/video/bst-thu-dong.mp4URL video công khai — nền tảng tự tải về.
namebodystringKhôngVideo BST Thu ĐôngTên video.
titlebodystringKhôngTiêu đề.
descriptionbodystringKhôngMô tả.

Ví dụ request

curl -s -X POST "https://partner.quantri360.com/v1/facebook/v25.0/act_1000000000000001/advideos" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"file_url":"https://example.com/video/bst-thu-dong.mp4","name":"Video BST Thu Đông"}'
Python
import requests

KEY = "q360_live_..."  # khóa API của brand
r = requests.post(
    "https://partner.quantri360.com/v1/facebook/v25.0/act_1000000000000001/advideos",
    params={},
    json={
        "file_url": "https://example.com/video/bst-thu-dong.mp4",
        "name": "Video BST Thu Đông"
    },
    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/act_1000000000000001/advideos');
for (const [k, v] of Object.entries({})) url.searchParams.set(k, typeof v === 'object' ? JSON.stringify(v) : String(v));
const r = await fetch(url, {
  method: 'POST',
  headers: { Authorization: `Bearer ${KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({"file_url":"https://example.com/video/bst-thu-dong.mp4","name":"Video BST Thu Đông"}),
});
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/act_1000000000000001/advideos' . '?' . http_build_query([]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $key, 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"file_url":"https://example.com/video/bst-thu-dong.mp4","name":"Video BST Thu Đông"}');
$res = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status, "\n", $res;

Response

Tham số phản hồi (nguyên của Facebook)

TênKiểuMẫuMô tả
idstring1000000000000012Id video — dùng `video_id` trong nội dung quảng cáo.

Mẫu phản hồi

{
  "id": "1000000000000012"
}

Bắt đầu dùng

  1. Đăng ký tài khoản Partner
  2. Mở loại dữ liệu thuộc nhóm Quảng cáo (Marketing API) ở trang nền tảng
  3. Tạo API key (tick kênh Facebook)
  4. Gọi theo ví dụ ở trên