Skip to content

Commit 98ebb31

Browse files
committed
Replace the deprecated use of new JsonParser with the use of its static methods
1 parent 280318a commit 98ebb31

File tree

215 files changed

+8756
-727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+8756
-727
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 AdAccountAdCreativesEdge {
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).getAdCreatives()
23+
.requestNameField()
24+
.execute();
25+
26+
}
27+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 AdAccountAdCreativesPost {
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+
.setName("Sample Promoted Post")
24+
.setObjectStoryId("<pageID>_<postID>")
25+
.execute();
26+
27+
}
28+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 AdAccountAdCreativesPostCreateAdCreative {
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+
.setObjectStoryId("<pageID>_<postID>")
24+
.execute();
25+
26+
}
27+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 AdAccountAdCreativesPostCreateAdCreativeCanvas {
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+
.setImageHash("<imageHash>")
24+
.setObjectStorySpec(
25+
new AdCreativeObjectStorySpec()
26+
.setFieldLinkData(
27+
new AdCreativeLinkData()
28+
.setFieldCallToAction(
29+
new AdCreativeLinkDataCallToAction()
30+
.setFieldType(AdCreativeLinkDataCallToAction.EnumType.VALUE_LEARN_MORE)
31+
)
32+
.setFieldImageHash("<imageHash>")
33+
.setFieldLink("<canvasURI>")
34+
.setFieldName("Creative message")
35+
)
36+
.setFieldPageId("<pageID>")
37+
)
38+
.execute();
39+
40+
}
41+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 AdAccountAdCreativesPostCreateAdCreativeCustomizationCanvasImage {
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+
.setFieldLinkData(
26+
new AdCreativeLinkData()
27+
.setFieldCallToAction(
28+
new AdCreativeLinkDataCallToAction()
29+
.setFieldType(AdCreativeLinkDataCallToAction.EnumType.VALUE_LEARN_MORE)
30+
)
31+
.setFieldCustomizationRulesSpec(Arrays.asList(
32+
new AdCustomizationRuleSpec()
33+
.setFieldCustomizationSpec("{\"language\":\"en_XX\"}")
34+
,
35+
new AdCustomizationRuleSpec()
36+
.setFieldCustomizationSpec("{\"language\":\"fr_XX\"}")
37+
.setFieldLink("<canvasURIFR>")
38+
.setFieldMessage("French Creative message")
39+
.setFieldName("French Creative title")
40+
))
41+
.setFieldLink("<canvasURI>")
42+
.setFieldMessage("English Creative message")
43+
.setFieldName("English Creative title")
44+
.setFieldPicture("<imageURL>")
45+
.setFieldRetailerItemIds(Arrays.asList(0L, 0L, 0L, 0L))
46+
)
47+
.setFieldPageId("<pageID>")
48+
)
49+
.setProductSetId("<productSetID>")
50+
.execute();
51+
52+
}
53+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 AdAccountAdCreativesPostCreateAdCreativeCustomizationCanvasVideo {
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+
.setFieldVideoData(
27+
new AdCreativeVideoData()
28+
.setFieldCallToAction(
29+
new AdCreativeLinkDataCallToAction()
30+
.setFieldType(AdCreativeLinkDataCallToAction.EnumType.VALUE_LEARN_MORE)
31+
.setFieldValue(
32+
new AdCreativeLinkDataCallToActionValue()
33+
.setFieldLink("<canvasURI>")
34+
)
35+
)
36+
.setFieldImageUrl("<imageURL>")
37+
.setFieldMessage("English Creative message")
38+
.setFieldRetailerItemIds(Arrays.asList(0L, 0L, 0L, 0L))
39+
.setFieldTitle("English Creative title")
40+
.setFieldVideoId("<videoID>")
41+
)
42+
)
43+
.setProductSetId("<productSetID>")
44+
.execute();
45+
46+
}
47+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 AdAccountAdCreativesPostEnrollStatus {
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+
.setName("Sample Promoted")
24+
.setObjectStorySpec(
25+
new AdCreativeObjectStorySpec()
26+
.setFieldLinkData(
27+
new AdCreativeLinkData()
28+
.setFieldImageHash("<imageHash>")
29+
.setFieldLink("<imageURL>")
30+
.setFieldMessage("try it out")
31+
)
32+
.setFieldPageId("<pageID>")
33+
)
34+
.setParam("degrees_of_freedom_spec", "{\"creative_features_spec\":\"{\"standard_enhancements\":\"{\\"enroll_status\\":\\"OPT_IN\\"}\"}\"}")
35+
.setParam("special_ad_categories", "[]")
36+
.execute();
37+
38+
}
39+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 AdAccountAdLabelsPost {
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).createAdLabel()
23+
.setName("My Label")
24+
.execute();
25+
26+
}
27+
}

examples/AdAccountAdSetsEdge.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 AdAccountAdSetsEdge {
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).getAdSets()
23+
.requestNameField()
24+
.requestIdField()
25+
.requestStatusField()
26+
.execute();
27+
28+
}
29+
}

0 commit comments

Comments
 (0)