素材信息库参数

通过 asset_feed_spec 字段,您可以向不同用户投放广告创意的不同组合。您可以通过以下两种方式设置广告创意组合:

  • 自动:您提供创意素材,系统会自动向不同用户投放不同的组合。如要使用此方法,请参阅动态素材 API
  • 手动:您提供创意素材,并亲自创建这些素材的投放方式规则。如要使用此方法,请参阅素材定制规则

素材信息库参数由一系列不同的创意元素组成,例如图片、标题和正文等。您可以为每种素材类型指定多个创意素材。素材信息库参数的格式因用例而异。另请参阅参考文档 > 素材信息库参数

创建素材信息库

您可以使用 asset_feed_spec 来提供多个创意素材,但是需要遵循以下限制:

  • 对于所有素材定制规则,需要在 asset_feed_spec 中加入至少两条目标定制规则。
  • 对于动态素材应在 asset_feed_spec 中加入定制规则。在这种情况下,您可以在 ad_formats 下指定 [“AUTOMATIC_FORMAT”],从而在不同版位将图片和视频混合使用。

例如,如要创建用于动态素材的 asset_feed_spec,可使用以下代码:

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/v21.0/act_<AD_ACCOUNT_ID>/adcreatives

您也可以创建包含两个备选视频、两个备选正文和两个备选标题的 asset_feed_spec

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

查看素材信息库参数的所有可用选项

读取素材信息库

如要检查您的创意,请读取 asset_feed_spec

curl -X GET \ -d 'fields="asset_feed_spec"' \ -d 'access_token=<ACCESS_TOKEN>' \ https://graph.facebook.com/v21.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')

如果您的动态素材信息库包含多个图片和正文,响应将如下所示:

{  
   "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>",
}

如果您的动态素材信息库包含多个视频、正文和标题,响应将如下所示:

{  
   "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>",
}

编辑素材信息库

您可以添加、替换或移除任何创意素材。如要执行该操作,请使用新的 asset_feed_spec 提供另一个创意。

您可以:

  • 添加素材。
  • 移除现有素材。
  • 使用全新素材替换已有素材。

不能执行以下操作:

  • 更改广告格式,例如从 SINGLE IMAGE 更改为 VIDEO
  • 将基于素材信息库的创意广告更新为没有 asset_feed_spec 的非动态素材广告。
    curl \
      -F 'access_token=<ACCESS_TOKEN>' \
      -F 'creative={
          "creative_id": <CREATIVE_ID>,
       }' \
    https://graph.facebook.com/v21.0/<AD_ID>

在创建用于替换旧广告创意的新广告创意时,您仍然必须满足所有适用的限制条件