Skip to content

Commit

Permalink
Merge branch 'main' into update-dependencies-to-latest-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
stcheng authored Dec 19, 2024
2 parents cfa8bfe + 49398af commit 6b8c65b
Show file tree
Hide file tree
Showing 215 changed files with 8,528 additions and 771 deletions.
27 changes: 27 additions & 0 deletions examples/AdAccountAdCreativesEdge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/

import com.facebook.ads.sdk.*;
import java.io.File;
import java.util.Arrays;

public class AdAccountAdCreativesEdge {
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_ACCOUNT_ID>";
APIContext context = new APIContext(access_token).enableDebug(true);

new AdAccount(id, context).getAdCreatives()
.requestNameField()
.execute();

}
}
28 changes: 28 additions & 0 deletions examples/AdAccountAdCreativesPost.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/

import com.facebook.ads.sdk.*;
import java.io.File;
import java.util.Arrays;

public class AdAccountAdCreativesPost {
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_ACCOUNT_ID>";
APIContext context = new APIContext(access_token).enableDebug(true);

new AdAccount(id, context).createAdCreative()
.setName("Sample Promoted Post")
.setObjectStoryId("<pageID>_<postID>")
.execute();

}
}
27 changes: 27 additions & 0 deletions examples/AdAccountAdCreativesPostCreateAdCreative.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/

import com.facebook.ads.sdk.*;
import java.io.File;
import java.util.Arrays;

public class AdAccountAdCreativesPostCreateAdCreative {
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_ACCOUNT_ID>";
APIContext context = new APIContext(access_token).enableDebug(true);

new AdAccount(id, context).createAdCreative()
.setObjectStoryId("<pageID>_<postID>")
.execute();

}
}
41 changes: 41 additions & 0 deletions examples/AdAccountAdCreativesPostCreateAdCreativeCanvas.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/

import com.facebook.ads.sdk.*;
import java.io.File;
import java.util.Arrays;

public class AdAccountAdCreativesPostCreateAdCreativeCanvas {
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_ACCOUNT_ID>";
APIContext context = new APIContext(access_token).enableDebug(true);

new AdAccount(id, context).createAdCreative()
.setImageHash("<imageHash>")
.setObjectStorySpec(
new AdCreativeObjectStorySpec()
.setFieldLinkData(
new AdCreativeLinkData()
.setFieldCallToAction(
new AdCreativeLinkDataCallToAction()
.setFieldType(AdCreativeLinkDataCallToAction.EnumType.VALUE_LEARN_MORE)
)
.setFieldImageHash("<imageHash>")
.setFieldLink("<canvasURI>")
.setFieldName("Creative message")
)
.setFieldPageId("<pageID>")
)
.execute();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/

import com.facebook.ads.sdk.*;
import java.io.File;
import java.util.Arrays;

public class AdAccountAdCreativesPostCreateAdCreativeCustomizationCanvasDV {
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_ACCOUNT_ID>";
APIContext context = new APIContext(access_token).enableDebug(true);

new AdAccount(id, context).createAdCreative()
.setObjectStorySpec(
new AdCreativeObjectStorySpec()
.setFieldPageId("<pageID>")
.setFieldTemplateData(
new AdCreativeLinkData()
.setFieldCallToAction(
new AdCreativeLinkDataCallToAction()
.setFieldType(AdCreativeLinkDataCallToAction.EnumType.VALUE_LEARN_MORE)
)
.setFieldCustomizationRulesSpec(Arrays.asList(
new AdCustomizationRuleSpec()
.setFieldCustomizationSpec("{\"language\":\"en_XX\"}")
,
new AdCustomizationRuleSpec()
.setFieldCustomizationSpec("{\"language\":\"fr_XX\"}")
.setFieldLink("<canvasURIFR>")
.setFieldMessage("French Creative message")
.setFieldName("French Creative title")
))
.setFieldFormatOption(AdCreativeLinkData.EnumFormatOption.VALUE_COLLECTION_VIDEO)
.setFieldLink("<canvasURI>")
.setFieldMessage("English Creative message")
.setFieldName("English Creative title")
.setFieldRetailerItemIds(Arrays.asList(0L, 0L, 0L, 0L))
)
)
.setProductSetId("<productSetID>")
.execute();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/

import com.facebook.ads.sdk.*;
import java.io.File;
import java.util.Arrays;

public class AdAccountAdCreativesPostCreateAdCreativeCustomizationCanvasImage {
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_ACCOUNT_ID>";
APIContext context = new APIContext(access_token).enableDebug(true);

new AdAccount(id, context).createAdCreative()
.setObjectStorySpec(
new AdCreativeObjectStorySpec()
.setFieldLinkData(
new AdCreativeLinkData()
.setFieldCallToAction(
new AdCreativeLinkDataCallToAction()
.setFieldType(AdCreativeLinkDataCallToAction.EnumType.VALUE_LEARN_MORE)
)
.setFieldCustomizationRulesSpec(Arrays.asList(
new AdCustomizationRuleSpec()
.setFieldCustomizationSpec("{\"language\":\"en_XX\"}")
,
new AdCustomizationRuleSpec()
.setFieldCustomizationSpec("{\"language\":\"fr_XX\"}")
.setFieldLink("<canvasURIFR>")
.setFieldMessage("French Creative message")
.setFieldName("French Creative title")
))
.setFieldLink("<canvasURI>")
.setFieldMessage("English Creative message")
.setFieldName("English Creative title")
.setFieldPicture("<imageURL>")
.setFieldRetailerItemIds(Arrays.asList(0L, 0L, 0L, 0L))
)
.setFieldPageId("<pageID>")
)
.setProductSetId("<productSetID>")
.execute();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/

import com.facebook.ads.sdk.*;
import java.io.File;
import java.util.Arrays;

public class AdAccountAdCreativesPostCreateAdCreativeCustomizationCanvasVideo {
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_ACCOUNT_ID>";
APIContext context = new APIContext(access_token).enableDebug(true);

new AdAccount(id, context).createAdCreative()
.setObjectStorySpec(
new AdCreativeObjectStorySpec()
.setFieldPageId("<pageID>")
.setFieldVideoData(
new AdCreativeVideoData()
.setFieldCallToAction(
new AdCreativeLinkDataCallToAction()
.setFieldType(AdCreativeLinkDataCallToAction.EnumType.VALUE_LEARN_MORE)
.setFieldValue(
new AdCreativeLinkDataCallToActionValue()
.setFieldLink("<canvasURI>")
)
)
.setFieldImageUrl("<imageURL>")
.setFieldMessage("English Creative message")
.setFieldRetailerItemIds(Arrays.asList(0L, 0L, 0L, 0L))
.setFieldTitle("English Creative title")
.setFieldVideoId("<videoID>")
)
)
.setProductSetId("<productSetID>")
.execute();

}
}
39 changes: 39 additions & 0 deletions examples/AdAccountAdCreativesPostEnrollStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/

import com.facebook.ads.sdk.*;
import java.io.File;
import java.util.Arrays;

public class AdAccountAdCreativesPostEnrollStatus {
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_ACCOUNT_ID>";
APIContext context = new APIContext(access_token).enableDebug(true);

new AdAccount(id, context).createAdCreative()
.setName("Sample Promoted")
.setObjectStorySpec(
new AdCreativeObjectStorySpec()
.setFieldLinkData(
new AdCreativeLinkData()
.setFieldImageHash("<imageHash>")
.setFieldLink("<imageURL>")
.setFieldMessage("try it out")
)
.setFieldPageId("<pageID>")
)
.setParam("degrees_of_freedom_spec", "{\"creative_features_spec\":\"{\"standard_enhancements\":\"{\\"enroll_status\\":\\"OPT_IN\\"}\"}\"}")
.setParam("special_ad_categories", "[]")
.execute();

}
}
27 changes: 27 additions & 0 deletions examples/AdAccountAdLabelsPost.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/

import com.facebook.ads.sdk.*;
import java.io.File;
import java.util.Arrays;

public class AdAccountAdLabelsPost {
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_ACCOUNT_ID>";
APIContext context = new APIContext(access_token).enableDebug(true);

new AdAccount(id, context).createAdLabel()
.setName("My Label")
.execute();

}
}
29 changes: 29 additions & 0 deletions examples/AdAccountAdSetsEdge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/

import com.facebook.ads.sdk.*;
import java.io.File;
import java.util.Arrays;

public class AdAccountAdSetsEdge {
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_ACCOUNT_ID>";
APIContext context = new APIContext(access_token).enableDebug(true);

new AdAccount(id, context).getAdSets()
.requestNameField()
.requestIdField()
.requestStatusField()
.execute();

}
}
Loading

0 comments on commit 6b8c65b

Please sign in to comment.