排定資料摘要上傳時程

本指南說明如何上傳和排定摘要。

上傳摘要

若要上傳摘要,您需要 catalog_management 權限。請參閱行銷 API:權限。建立目錄後,使用 catalog id 來建立和排定產品摘要

curl -X POST \ -F 'name="Test Feed"' \ -F 'schedule={ "interval": "DAILY", "url": "http://www.example.com/sample_feed.tsv", "hour": "22" }' \ -F 'access_token=<ACCESS_TOKEN>' \ https://graph.facebook.com/v20.0/{product-catalog-id}/product_feeds
'use strict'; const bizSdk = require('facebook-nodejs-business-sdk'); const ProductCatalog = bizSdk.ProductCatalog; const ProductFeed = bizSdk.ProductFeed; const access_token = '<ACCESS_TOKEN>'; const app_secret = '<APP_SECRET>'; const app_id = '<APP_ID>'; const id = '<PRODUCT_CATALOG_ID>'; const api = bizSdk.FacebookAdsApi.init(access_token); const showDebugingInfo = true; // Setting this to true shows more debugging info. if (showDebugingInfo) { api.setDebug(true); } const logApiCallResult = (apiCallName, data) => { console.log(apiCallName); if (showDebugingInfo) { console.log('Data:' + JSON.stringify(data)); } }; let fields, params; fields = [ ]; params = { 'name' : 'Test Feed', 'schedule' : {'interval':'DAILY','url':'http://www.example.com/sample_feed.tsv','hour':'22'}, }; const product_feeds = (new ProductCatalog(id)).createProductFeed( fields, params ); logApiCallResult('product_feeds api call complete.', product_feeds);
require __DIR__ . '/vendor/autoload.php'; use FacebookAds\Object\ProductCatalog; use FacebookAds\Object\ProductFeed; use FacebookAds\Api; use FacebookAds\Logger\CurlLogger; $access_token = '<ACCESS_TOKEN>'; $app_secret = '<APP_SECRET>'; $app_id = '<APP_ID>'; $id = '<PRODUCT_CATALOG_ID>'; $api = Api::init($app_id, $app_secret, $access_token); $api->setLogger(new CurlLogger()); $fields = array( ); $params = array( 'name' => 'Test Feed', 'schedule' => array('interval' => 'DAILY','url' => 'http://www.example.com/sample_feed.tsv','hour' => '22'), ); echo json_encode((new ProductCatalog($id))->createProductFeed( $fields, $params )->exportAllData(), JSON_PRETTY_PRINT);
from facebook_business.adobjects.productcatalog import ProductCatalog from facebook_business.adobjects.productfeed import ProductFeed from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<PRODUCT_CATALOG_ID>' FacebookAdsApi.init(access_token=access_token) fields = [ ] params = { 'name': 'Test Feed', 'schedule': {'interval':'DAILY','url':'http://www.example.com/sample_feed.tsv','hour':'22'}, } print ProductCatalog(id).create_product_feed( fields=fields, params=params, )
import com.facebook.ads.sdk.*; import java.io.File; import java.util.Arrays; public class SAMPLE_CODE_EXAMPLE { public static void main (String args[]) throws APIException { String access_token = \"<ACCESS_TOKEN>\"; String app_secret = \"<APP_SECRET>\"; String app_id = \"<APP_ID>\"; String id = \"<PRODUCT_CATALOG_ID>\"; APIContext context = new APIContext(access_token).enableDebug(true); new ProductCatalog(id, context).createProductFeed() .setName(\"Test Feed\") .setSchedule(\"{\\"interval\\":\\"DAILY\\",\\"url\\":\\"http://www.example.com/sample_feed.tsv\\",\\"hour\\":\\"22\\"}\") .execute(); } }
require 'facebook_ads' access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<PRODUCT_CATALOG_ID>' FacebookAds.configure do |config| config.access_token = access_token config.app_secret = app_secret end product_catalog = FacebookAds::ProductCatalog.get(id) product_feeds = product_catalog.product_feeds.create({ name: 'Test Feed', schedule: {'interval':'DAILY','url':'http://www.example.com/sample_feed.tsv','hour':'22'}, })

schedule 參數可讓您排定摘要上傳時程。選項包含 intervalurlhour,也可以包含 day_of_weekminuteusernamepassword

注意:針對 usernamepassword,我們支援 HTTP 和 FTP 上的基本驗證。

範例:排定摘要上傳時程

schedule: {"day_of_week":"FRIDAY","hour":17,"interval_count":1,"interval":"DAILY","minute":42,"next_scheduled_upload_time":"","password":pwd123,"status":"active","timezone":"Atlantic/Canary","url":"https://www.abc.com","username":aname}

更新個別商品

即時更新個別商品的資料。將已更新的欄位包含在 HTTP POST 中,其中 retailer_id 是從摘要取得的商品編號,必須是 base64url 編碼。

https://graph.facebook.com/catalog:{CATALOG_ID}:{base64urlencode(retailer_id)}

請參閱參考資料:產品中的可變欄位。

請勿以透過 API 更新、建立或刪除個別商品的方式來提供商品摘要。這樣可能會在更新或刪除透過 API 建立的商品時造成中斷,因為我們不會使用摘要來追蹤這些商品。

排定資料摘要擷取時程

排定的摘要不支援超過每小時一次的上傳頻率。如果您需要加快更新庫存的頻率,建議您使用直接上傳 API

如果您使用我們的 API 來建立和管理您的摘要,您需要傳送 API 要求給我們,提供所要建立的更新排程詳細資訊:

curl \
  -F 'name=Test Feed' \
  -F 'update_schedule={ 
    "interval": "HOURLY", 
    "url": "http:\/\/www.example.com\/sample_feed_updates.tsv",
    "hour": 22
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/<API_VERSION>/<CATALOG_ID>/product_feeds

我們會依照您定義的排程,從您的系統擷取商品摘要。您可以定義的排程類型有兩種:

  • update_schedule — 上傳時會以資料摘要檔案中提供的資訊來建立新的商品或更新現有的商品。
  • schedule — 上傳時會導致對資料摘要進行完整的重新整理作業。我們會刪除檔案中不存在的商品、更新現有商品,以及建立新商品。您可以視需要使用其中一種排程,或兩種排程都使用。

例如:update_schedule 的頻率為 HOURLY,以及替換 schedule 的頻率為 DAILY

建議您設定 update_schedule 時,只包含資料摘要檔案中的變更資料,以加快處理摘要的速度。這對於節日促銷特別有幫助,可加速更新價格和供應情況。另外也建議將商品標示為「缺貨」,而不要從摘要中刪除,讓我們能夠以類似的可供應商品再次鎖定用戶。

curl \
  -F 'name=Test Feed' \
  -F 'schedule={ 
    "interval": "DAILY", 
    "url": "http:\/\/www.example.com\/sample_feed.tsv"
  }' \
  -F 'update_schedule={ 
    "interval": "HOURLY", 
    "url": "http:\/\/www.example.com\/sample_feed_updates.tsv",
    "hour": 22
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/<API_VERSION>/<CATALOG_ID>/product_feeds

回應:

{ "id" : {FEED_ID} }

請參閱資料摘要參考資料資料摘要排程參考資料