1+ /*
2+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3+ * All rights reserved.
4+ *
5+ * This source code is licensed under the license found in the
6+ * LICENSE file in the root directory of this source tree.
7+ */
8+
9+ import com .facebook .ads .sdk .*;
10+ import java .io .File ;
11+ import java .util .Arrays ;
12+
13+ public class AdAccountAdCreativesPostCreateAdCreativeCustomizationCanvasDV {
14+ public static void main (String args []) throws APIException {
15+
16+ String access_token = "<ACCESS_TOKEN>" ;
17+ String app_secret = "<APP_SECRET>" ;
18+ String app_id = "<APP_ID>" ;
19+ String id = "<AD_ACCOUNT_ID>" ;
20+ APIContext context = new APIContext (access_token ).enableDebug (true );
21+
22+ new AdAccount (id , context ).createAdCreative ()
23+ .setObjectStorySpec (
24+ new AdCreativeObjectStorySpec ()
25+ .setFieldPageId ("<pageID>" )
26+ .setFieldTemplateData (
27+ new AdCreativeLinkData ()
28+ .setFieldCallToAction (
29+ new AdCreativeLinkDataCallToAction ()
30+ .setFieldType (AdCreativeLinkDataCallToAction .EnumType .VALUE_LEARN_MORE )
31+ )
32+ .setFieldCustomizationRulesSpec (Arrays .asList (
33+ new AdCustomizationRuleSpec ()
34+ .setFieldCustomizationSpec ("{\" language\" :\" en_XX\" }" )
35+ ,
36+ new AdCustomizationRuleSpec ()
37+ .setFieldCustomizationSpec ("{\" language\" :\" fr_XX\" }" )
38+ .setFieldLink ("<canvasURIFR>" )
39+ .setFieldMessage ("French Creative message" )
40+ .setFieldName ("French Creative title" )
41+ ))
42+ .setFieldFormatOption (AdCreativeLinkData .EnumFormatOption .VALUE_COLLECTION_VIDEO )
43+ .setFieldLink ("<canvasURI>" )
44+ .setFieldMessage ("English Creative message" )
45+ .setFieldName ("English Creative title" )
46+ .setFieldRetailerItemIds (Arrays .asList (0L , 0L , 0L , 0L ))
47+ )
48+ )
49+ .setProductSetId ("<productSetID>" )
50+ .execute ();
51+
52+ }
53+ }
0 commit comments