# API Documentation for Audience Management ### 請求網址 測試環境 https://beta.ecpaydata.com.tw/data-ta 正式環境 https://dash.ecpaydata.com.tw/data-ta ## 1. 取得 Facebook API Token (settings) 取得 Facebook APPID 與 TOKEN,用於受眾名單上傳 ### 請求參數 | 欄位 | 格式 | 必填 | 說明 | | ------------ | ------- | -------------- | -------------------------------------------------- | | act | string | * | 預設帶入: settings | | api_token | string | * | 驗證用的 API token | ### 範例請求 ```bash curl -X POST https://beta.ecpaydata.com.tw/data-ta \ -d act=settings \ -d api_token=token \ ``` ### 範例回應 ```json= { "code": 200, "app_id": "1871792159951639", "refresh_token": "token", "accounts": [ { "id": "1169244650931455", "name": "ECPaydata-001" }, { "id": "7613050415458666", "name": "ECPaydata-002" }, ] } ``` ## 2. 建立新受眾名單 (create_audience) 發出建立受眾名單請求,並回傳受眾名單建立狀態碼與訊息。 ### 請求參數 | 欄位 | 格式 | 必填 | 說明 | | ------------ | ------- | -------------- | -------------------------------------------------- | | act | string | * | 預設帶入: create_audience | | api_token | string | * | 驗證用的 API token | | audience_id | integer | * | 受眾名單 ID(上傳名單至 FB 後取得) | | ad_account_id | integer | * | FB 帳戶 ID | | SubTypeID | string | * | 次分類ID (UUID) | | tag_name | string | * | 標籤名稱 | | app_id | integer | * | 應用 ID | | type | string | * | 受眾名單類型:facebook | ### 範例請求 ```bash curl -X POST https://beta.ecpaydata.com.tw/data-ta \ -d act=create_audience \ -d api_token=token \ -d audience_id=12345 \ -d ad_account_id=67890 \ -d SubTypeID={UUID} \ -d app_id=222 \ -d type="facebook" ``` ### 範例回應 成功建立受眾名單: ```json= { "code": 200, "msg": "受眾名單已成功建立" } ``` --- ## 3. 關鍵字反查主分類 (tag_2_maintype) ### 請求參數 | 欄位 | 格式 | 必填 | 說明 | | ------------ | ------- | -------------- | -------------------------------------------------- | | act | string | * | 預設帶入: tag_2_maintype | | api_token | string | * | 驗證用的 API token | | tag | string | * | 標籤名稱 | ### 範例請求 ```bash curl -X POST https://beta.ecpaydata.com.tw/data-ta \ -d act=tag_2_maintype \ -d api_token=token \ -d tag="128G" ``` ### 範例回應 成功建立受眾名單: ```json= { "code": 200, "data": [ { "ProductTypeName": "手機平板與周邊" }, { "ProductTypeName": "3C與筆電" } ] } ``` --- ## 4. 分析 Product Feed 並回傳 Tags 與主、次分類 ### 請求參數 | 欄位 | 格式 | 必填 | 說明 | | ------------ | ------- | -------------- | -------------------------------------------------- | | act | string | * | 預設帶入: analytics_product_feed | | api_token | string | * | 驗證用的 API token | | url | string | * | Product Feed RSS 網址 | ### 範例請求 可以用以下URL測試 https://shopline-feeds.s3.amazonaws.com/facebook_featured_products/tomali.xml ```bash curl -X POST https://beta.ecpaydata.com.tw/data-ta \ -d act=analytics_product_feed \ -d api_token=token \ -d url="https://www.bvgcorp.net/projects/test/products.xml" ``` ### 範例回應 隨機抽20個商品,並找出相關 Tag, 以及每個 Tag 分布的前五個最接近的主、次分類: ```json= { "code": 200, "data": [ { "title": "比利時Trixie 有機棉兩件式長袖家居服-甜心檸檬", "tags": [ { "tag": "家居服", "tagID": 102047, "subTypes": [ { "SubTypeID": "d9482772-5120-11ee-ac9a-42010a40000b", "SubTypeName": "內睡衣", "MainTypeID": "d9481a9c-5120-11ee-ac9a-42010a40000b", "MainTypeName": "服飾", "qty": 1015 }, { "SubTypeID": "ecd0586a-bfe0-11ee-99ca-42010a2f7007", "SubTypeName": "其他服飾", "MainTypeID": "d9481a9c-5120-11ee-ac9a-42010a40000b", "MainTypeName": "服飾", "qty": 457 }, { "SubTypeID": "d9482bfe-5120-11ee-ac9a-42010a40000b", "SubTypeName": "休閒運動服飾", "MainTypeID": "d9481a9c-5120-11ee-ac9a-42010a40000b", "MainTypeName": "服飾", "qty": 147 }, { "SubTypeID": "d948f186-5120-11ee-ac9a-42010a40000b", "SubTypeName": "嬰幼童用品", "MainTypeID": "d948ecc8-5120-11ee-ac9a-42010a40000b", "MainTypeName": "嬰幼童與母親", "qty": 90 }, { "SubTypeID": "d94827d7-5120-11ee-ac9a-42010a40000b", "SubTypeName": "外套", "MainTypeID": "d9481a9c-5120-11ee-ac9a-42010a40000b", "MainTypeName": "服飾", "qty": 77 } ] }, { "tag": "有機棉", "tagID": 100496, "subTypes": [ { "SubTypeID": "ecd0586a-bfe0-11ee-99ca-42010a2f7007", "SubTypeName": "其他服飾", "MainTypeID": "d9481a9c-5120-11ee-ac9a-42010a40000b", "MainTypeName": "服飾", "qty": 2873 }, { "SubTypeID": "d948f186-5120-11ee-ac9a-42010a40000b", "SubTypeName": "嬰幼童用品", "MainTypeID": "d948ecc8-5120-11ee-ac9a-42010a40000b", "MainTypeName": "嬰幼童與母親", "qty": 2778 }, { "SubTypeID": "d9482134-5120-11ee-ac9a-42010a40000b", "SubTypeName": "T恤", "MainTypeID": "d9481a9c-5120-11ee-ac9a-42010a40000b", "MainTypeName": "服飾", "qty": 2707 }, { "SubTypeID": "d948f1c4-5120-11ee-ac9a-42010a40000b", "SubTypeName": "嬰幼兒裝", "MainTypeID": "d948ecc8-5120-11ee-ac9a-42010a40000b", "MainTypeName": "嬰幼童與母親", "qty": 1450 }, { "SubTypeID": "d9482bfe-5120-11ee-ac9a-42010a40000b", "SubTypeName": "休閒運動服飾", "MainTypeID": "d9481a9c-5120-11ee-ac9a-42010a40000b", "MainTypeName": "服飾", "qty": 1418 } ] } ] } } ```