1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
3
+ *
4
+ * You are hereby granted a non-exclusive, worldwide, royalty-free license to
5
+ * use, copy, modify, and distribute this software in source code or binary
6
+ * form for use in connection with the web services and APIs provided by
7
+ * Facebook.
8
+ *
9
+ * As with any software that integrates with the Facebook platform, your use
10
+ * of this software is subject to the Facebook Developer Principles and
11
+ * Policies [http://developers.facebook.com/policy/]. This copyright notice
12
+ * shall be included in all copies or substantial portions of the software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20
+ * DEALINGS IN THE SOFTWARE.
21
+ *
22
+ */
23
+
24
+ import com .facebook .ads .sdk .*;
25
+ import java .io .File ;
26
+ import java .util .Arrays ;
27
+
28
+ public class AdAccountAdCreativesPost2CreateCarouselCallToActionAppInstall {
29
+ public static void main (String args []) throws APIException {
30
+
31
+ String access_token = "<ACCESS_TOKEN>" ;
32
+ String app_secret = "<APP_SECRET>" ;
33
+ String app_id = "<APP_ID>" ;
34
+ String id = "<AD_ACCOUNT_ID>" ;
35
+ APIContext context = new APIContext (access_token ).enableDebug (true );
36
+
37
+ new AdAccount (id , context ).createAdCreative ()
38
+ .setName ("Carousel app ad" )
39
+ .setObjectStorySpec (
40
+ new AdCreativeObjectStorySpec ()
41
+ .setFieldLinkData (
42
+ new AdCreativeLinkData ()
43
+ .setFieldCaption ("WWW.ITUNES.COM" )
44
+ .setFieldChildAttachments (Arrays .asList (
45
+ new AdCreativeLinkDataChildAttachment ()
46
+ .setFieldCallToAction (
47
+ new AdCreativeLinkDataCallToAction ()
48
+ .setFieldType (AdCreativeLinkDataCallToAction .EnumType .VALUE_USE_MOBILE_APP )
49
+ .setFieldValue (
50
+ new AdCreativeLinkDataCallToActionValue ()
51
+ .setFieldAppLink ("<deepLink>" )
52
+ )
53
+ )
54
+ .setFieldImageHash ("<imageHash>" )
55
+ .setFieldLink ("http://www.example.com/appstoreurl" )
56
+ ,
57
+ new AdCreativeLinkDataChildAttachment ()
58
+ .setFieldCallToAction (
59
+ new AdCreativeLinkDataCallToAction ()
60
+ .setFieldType (AdCreativeLinkDataCallToAction .EnumType .VALUE_USE_MOBILE_APP )
61
+ .setFieldValue (
62
+ new AdCreativeLinkDataCallToActionValue ()
63
+ .setFieldAppLink ("<deepLink>" )
64
+ )
65
+ )
66
+ .setFieldImageHash ("<imageHash>" )
67
+ .setFieldLink ("http://www.example.com/appstoreurl" )
68
+ ,
69
+ new AdCreativeLinkDataChildAttachment ()
70
+ .setFieldCallToAction (
71
+ new AdCreativeLinkDataCallToAction ()
72
+ .setFieldType (AdCreativeLinkDataCallToAction .EnumType .VALUE_USE_MOBILE_APP )
73
+ .setFieldValue (
74
+ new AdCreativeLinkDataCallToActionValue ()
75
+ .setFieldAppLink ("<deepLink>" )
76
+ )
77
+ )
78
+ .setFieldImageHash ("<imageHash>" )
79
+ .setFieldLink ("http://www.example.com/appstoreurl" )
80
+ ,
81
+ new AdCreativeLinkDataChildAttachment ()
82
+ .setFieldCallToAction (
83
+ new AdCreativeLinkDataCallToAction ()
84
+ .setFieldType (AdCreativeLinkDataCallToAction .EnumType .VALUE_USE_MOBILE_APP )
85
+ .setFieldValue (
86
+ new AdCreativeLinkDataCallToActionValue ()
87
+ .setFieldAppLink ("<deepLink>" )
88
+ )
89
+ )
90
+ .setFieldImageHash ("<imageHash>" )
91
+ .setFieldLink ("http://www.example.com/appstoreurl" )
92
+ ))
93
+ .setFieldDescription ("The link description" )
94
+ .setFieldLink ("http://www.example.com/appstoreurl" )
95
+ .setFieldMessage ("My message" )
96
+ .setFieldMultiShareOptimized (true )
97
+ .setFieldName ("The link name" )
98
+ )
99
+ .setFieldPageId ("<pageID>" )
100
+ )
101
+ .execute ();
102
+
103
+ }
104
+ }
0 commit comments