Quy cách nguồn cấp dữ liệu tài sản

Với trường asset_feed_spec, bạn có thể phân phối nội dung quảng cáo theo nhiều kiểu kết hợp cho những người dùng khác nhau. Có 2 cách thiết lập kiểu kết hợp:

  • Tự động: Bạn cung cấp tài sản nội dung và chúng tôi tự động phân phối nhiều kiểu kết hợp cho những người dùng khác nhau. Nếu bạn muốn sử dụng tùy chọn này, hãy xem bài viết API Nội dung động.
  • Thủ công: Bạn cung cấp tài sản nội dung và tạo quy tắc về cách hiển thị những tài sản đó. Nếu bạn muốn sử dụng tùy chọn này, hãy xem bài viết Quy tắc tùy chỉnh tài sản.

Quy cách nguồn cấp dữ liệu tài sản chứa một tập hợp các thành phần nội dung khác nhau, chẳng hạn như hình ảnh, tiêu đề, nội dung, v.v. Bạn có thể chỉ định nhiều tài sản nội dung cho từng loại tài sản. Mỗi trường hợp sử dụng sẽ có định dạng quy cách khác nhau. Hãy xem thêm Tài liệu tham khảo, Quy cách nguồn cấp dữ liệu tài sản.

Tạo nguồn cấp dữ liệu tài sản

Bạn có thể sử dụng asset_feed_spec để cung cấp nhiều tài sản nội dung, với những giới hạn sau đây:

  • Đối với tất cả Quy tắc tùy chỉnh tài sản, hãy thêm ít nhất 2 quy tắc tùy chỉnh mục tiêu vào asset_feed_spec.
  • Đối với Nội dung động, asset_feed_speckhông được có quy tắc tùy chỉnh. Trong trường hợp này, bạn có thể kết hợp cả hình ảnh và video trên các vị trí quảng cáo khác nhau, bằng cách chỉ định [“AUTOMATIC_FORMAT”] trong ad_formats.

Ví dụ: cách tạo asset_feed_spec cho Nội dung động như sau:

curl -X POST \
  -F 'name="Dynamic Ad Creative with Asset Feed Spec Sample"' \
  -F 'object_story_spec={
       "page_id": "<PAGE_ID>"
     }' \
  -F 'asset_feed_spec={
       "images": [
         {
           "hash": "<IMAGE_HASH>"
         }
       ],
       "bodies": [
         {
           "text": "Begin Your Adventure"
         },
         {
           "text": "Once a Trainer, always a Trainer."
         }
       ],
       "titles": [
         {
           "text": "Level Up"
         },
         {
           "text": "Swipe to evolve"
         }
       ],
       "descriptions": [
         {
           "text": "First Dynamic Ad Creative Sample"
         }
       ],
       "ad_formats": [
         "SINGLE_IMAGE"
       ],
       "call_to_action_types": [
         "SHOP_NOW"
       ],
       "link_urls": [
         {
           "website_url": "https://www.example.com/"
         }
       ],
       "videos": []
     }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v19.0/act_<AD_ACCOUNT_ID>/adcreatives

Bạn cũng có thể tạo asset_feed_spec có 2 video, nội dung và tiêu đề thay thế:

curl 
-F 'object_story_spec={
       "page_id": "YOUR_PAGE_ID"
       "instagram_actor_id" : "INSTAGRAM_ACTOR_ID",
    }' 
-F "asset_feed_spec={'videos': [{'video_id':'2053108854721025', 'thumbnail_url':'<thumnail_url>', 'url_tags':'video=video1'},{'video_id':'2104406249780616', 'thumbnail_url':'<thumnail_url>','url_tags':'video=video2'}], 'bodies': [{'text':'Begin Your Adventure'}, {'text':'Once a Trainer, always a Trainer.'}], 'titles': [{'text':'Level Up'}, {'text':'Swipe to evolve'}], 'descriptions': [{'text':'Begin Your Adventure'}], 'ad_formats': ['SINGLE_IMAGE'], 'link_urls': [{'website_url':'<WEBSITE_URL>'}]}"
-F 'access_token=<ACCESS_TOKEN>'  
https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/adcreatives

Xem tất cả tùy chọn có sẵn cho Quy cách nguồn cấp dữ liệu tài sản.

Đọc nguồn cấp dữ liệu tài sản

Để kiểm tra nội dung, hãy đọc asset_feed_spec như sau:

curl -X GET \ -d 'fields="asset_feed_spec"' \ -d 'access_token=<ACCESS_TOKEN>' \ https://graph.facebook.com/v19.0/<CREATIVE_ID>/
'use strict'; const bizSdk = require('facebook-nodejs-business-sdk'); const AdCreative = bizSdk.AdCreative; const access_token = '<ACCESS_TOKEN>'; const app_secret = '<APP_SECRET>'; const app_id = '<APP_ID>'; const id = '<AD_CREATIVE_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 = [ 'asset_feed_spec', ]; params = { }; const sample_code = (new AdCreative(id)).get( fields, params ); logApiCallResult('sample_code api call complete.', sample_code);
require __DIR__ . '/vendor/autoload.php'; use FacebookAds\Object\AdCreative; use FacebookAds\Api; use FacebookAds\Logger\CurlLogger; $access_token = '<ACCESS_TOKEN>'; $app_secret = '<APP_SECRET>'; $app_id = '<APP_ID>'; $id = '<AD_CREATIVE_ID>'; $api = Api::init($app_id, $app_secret, $access_token); $api->setLogger(new CurlLogger()); $fields = array( 'asset_feed_spec', ); $params = array( ); echo json_encode((new AdCreative($id))->getSelf( $fields, $params )->exportAllData(), JSON_PRETTY_PRINT);
from facebook_business.adobjects.adcreative import AdCreative from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<AD_CREATIVE_ID>' FacebookAdsApi.init(access_token=access_token) fields = [ 'asset_feed_spec', ] params = { } print AdCreative(id).get( 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 = \"<AD_CREATIVE_ID>\"; APIContext context = new APIContext(access_token).enableDebug(true); new AdCreative(id, context).get() .requestAssetFeedSpecField() .execute(); } }
require 'facebook_ads' access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<AD_CREATIVE_ID>' FacebookAds.configure do |config| config.access_token = access_token config.app_secret = app_secret end ad_creative = FacebookAds::AdCreative.get(id ,'asset_feed_spec')

Nếu bạn có nguồn cấp dữ liệu Nội dung động với nhiều hình ảnh và nội dung, phản hồi sẽ có dạng như sau:

{  
   "asset_feed_spec":{  
      "images":[  
         {  
            "url_tags":"image=image1",
            "hash":"785095162a2034666e0d0cc4ea1faf89"
         },
         {  
            "url_tags":"image=image2",
            "hash":"3a24122c13923569599be35567ce4e9e"
         }
      ],
      "bodies":[  
         {  
            "text":"Begin Your Adventure"
         },
         {  
            "text":"Once a Trainer, always a Trainer."
         }
      ],
      "call_to_action_types":[  
         "LEARN_MORE"
      ],
      "call_to_actions":[  
         {  
            "type":"LEARN_MORE"
         }
      ],
      "descriptions":[  
         {  
            "text":"Begin Your Adventure"
         }
      ],
      "link_urls":[  
         {  
            "website_url":"<WEBSITE_URL>"
         }
      ],
      "titles":[  
         {  
            "text":"Swipe to evolve"
         },
         {  
            "text":"Level Up"
         }
      ],
      "ad_formats":[  
         "SINGLE_IMAGE"
      ],
      "optimization_type":"REGULAR"
   },
   "id":"<AD_CREATIVE_ID>",
}

Nếu bạn có nguồn cấp dữ liệu Nội dung động với nhiều video, nội dung và tiêu đề, phản hồi sẽ có dạng như sau:

{  
   "asset_feed_spec":{  
      "videos":[  
         {  
            "url_tags":"video=video1",
            "video_id":"2053108854721025",
            "thumbnail_url":"<thumnail_url>",
            "thumbnail_hash":"<thumnail_hash>"
         },
         {  
            "url_tags":"video=video2",
            "video_id":"2104406249780616",
            "thumbnail_url":"<thumnail_url>",
            "thumbnail_hash":"<thumnail_hash>"
         }
      ],
      "bodies":[  
         {  
            "text":"Begin Your Adventure"
         },
         {  
            "text":"Once a Trainer, always a Trainer."
         }
      ],
      "call_to_action_types":[  
         "LEARN_MORE"
      ],
      "call_to_actions":[  
         {  
            "type":"LEARN_MORE"
         }
      ],
      "descriptions":[  
         {  
            "text":"Begin Your Adventure"
         }
      ],
      "link_urls":[  
         {  
            "website_url":"<WEBSITE_URL>"
         }
      ],
      "titles":[  
         {  
            "text":"Swipe to evolve"
         },
         {  
            "text":"Level Up"
         }
      ],
      "ad_formats":[  
         "SINGLE_VIDEO"
      ],
      "optimization_type":"REGULAR"
   },
   "id":"<AD_CREATIVE_ID>",
}

Chỉnh sửa nguồn cấp dữ liệu tài sản

Bạn có thể thêm, thay thế hoặc gỡ bất kỳ tài sản nội dung nào. Để thực hiện, hãy cung cấp một nội dung khác có asset_feed_spec mới.

Bạn có thể:

  • Thêm tài sản.
  • Gỡ tài sản hiện có.
  • Thay thế tài sản bằng tài sản hoàn toàn mới.

Bạn không thể:

  • Thay đổi định dạng quảng cáo, chẳng hạn như từ SINGLE IMAGE thành VIDEO.
  • Cập nhật quảng cáo chứa nội dung dựa trên Nguồn cấp dữ liệu tài sản thành quảng cáo chứa nội dung không phải Nội dung động (không có asset_feed_spec).
curl 
  -F 'access_token=<ACCESS_TOKEN>' 
  -F 'creative={
      "creative_id": <CREATIVE_ID>,
   }' 
https://graph.facebook.com/<API-VERSION>/<AD_ID>

Khi tạo nội dung quảng cáo mới để thay thế nội dung cũ, bạn vẫn phải tuân thủ tất cả quy định hạn chế được áp dụng.