use of com.google.api.ads.admanager.axis.v202205.ImageRedirectCreative in project googleads-java-lib by googleads.
the class CreateCreatives method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param advertiserId the ID of the advertiser (company) that all creatives will be assigned to.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
* @throws IOException if unable to get media data from the URL.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long advertiserId) throws IOException {
// Get the CreativeService.
CreativeServiceInterface creativeService = adManagerServices.get(session, CreativeServiceInterface.class);
// Create creative size.
Size size = new Size();
size.setWidth(600);
size.setHeight(315);
size.setIsAspectRatio(false);
// Create an image creative.
ImageCreative imageCreative = new ImageCreative();
imageCreative.setName("Image creative #" + new Random().nextInt(Integer.MAX_VALUE));
imageCreative.setAdvertiserId(advertiserId);
imageCreative.setDestinationUrl("http://google.com");
imageCreative.setSize(size);
// Create image asset.
CreativeAsset creativeAsset = new CreativeAsset();
creativeAsset.setFileName("image.jpg");
creativeAsset.setAssetByteArray(Media.getMediaDataFromUrl("https://goo.gl/3b9Wfh"));
creativeAsset.setSize(size);
imageCreative.setPrimaryImageAsset(creativeAsset);
// Create an image redirect creative.
ImageRedirectCreative imageRedirectCreative = new ImageRedirectCreative();
imageRedirectCreative.setName("Image redirect creative #" + new Random().nextInt(Integer.MAX_VALUE));
imageRedirectCreative.setAdvertiserId(advertiserId);
imageRedirectCreative.setDestinationUrl("http://google.com");
imageRedirectCreative.setImageUrl("https://goo.gl/3b9Wfh");
imageRedirectCreative.setSize(size);
// Create the creatives on the server.
Creative[] creatives = creativeService.createCreatives(new Creative[] { imageCreative, imageRedirectCreative });
for (Creative createdCreative : creatives) {
System.out.printf("A creative with ID %d, name '%s', and type '%s'" + " was created and can be previewed at: %s%n", createdCreative.getId(), createdCreative.getName(), createdCreative.getClass().getSimpleName(), createdCreative.getPreviewUrl());
}
}
use of com.google.api.ads.admanager.axis.v202205.ImageRedirectCreative in project googleads-java-lib by googleads.
the class CreateCreatives method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param advertiserId the ID of the advertiser (company) that all creatives will be assigned to.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
* @throws IOException if unable to get media data from the URL.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long advertiserId) throws IOException {
// Get the CreativeService.
CreativeServiceInterface creativeService = adManagerServices.get(session, CreativeServiceInterface.class);
// Create creative size.
Size size = new Size();
size.setWidth(600);
size.setHeight(315);
size.setIsAspectRatio(false);
// Create an image creative.
ImageCreative imageCreative = new ImageCreative();
imageCreative.setName("Image creative #" + new Random().nextInt(Integer.MAX_VALUE));
imageCreative.setAdvertiserId(advertiserId);
imageCreative.setDestinationUrl("http://google.com");
imageCreative.setSize(size);
// Create image asset.
CreativeAsset creativeAsset = new CreativeAsset();
creativeAsset.setFileName("image.jpg");
creativeAsset.setAssetByteArray(Media.getMediaDataFromUrl("https://goo.gl/3b9Wfh"));
creativeAsset.setSize(size);
imageCreative.setPrimaryImageAsset(creativeAsset);
// Create an image redirect creative.
ImageRedirectCreative imageRedirectCreative = new ImageRedirectCreative();
imageRedirectCreative.setName("Image redirect creative #" + new Random().nextInt(Integer.MAX_VALUE));
imageRedirectCreative.setAdvertiserId(advertiserId);
imageRedirectCreative.setDestinationUrl("http://google.com");
imageRedirectCreative.setImageUrl("https://goo.gl/3b9Wfh");
imageRedirectCreative.setSize(size);
// Create the creatives on the server.
Creative[] creatives = creativeService.createCreatives(new Creative[] { imageCreative, imageRedirectCreative });
for (Creative createdCreative : creatives) {
System.out.printf("A creative with ID %d, name '%s', and type '%s'" + " was created and can be previewed at: %s%n", createdCreative.getId(), createdCreative.getName(), createdCreative.getClass().getSimpleName(), createdCreative.getPreviewUrl());
}
}
use of com.google.api.ads.admanager.axis.v202205.ImageRedirectCreative in project googleads-java-lib by googleads.
the class CreateCreatives method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param advertiserId the ID of the advertiser (company) that all creatives will be assigned to.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
* @throws IOException if unable to get media data from the URL.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long advertiserId) throws IOException {
// Get the CreativeService.
CreativeServiceInterface creativeService = adManagerServices.get(session, CreativeServiceInterface.class);
// Create creative size.
Size size = new Size();
size.setWidth(600);
size.setHeight(315);
size.setIsAspectRatio(false);
// Create an image creative.
ImageCreative imageCreative = new ImageCreative();
imageCreative.setName("Image creative #" + new Random().nextInt(Integer.MAX_VALUE));
imageCreative.setAdvertiserId(advertiserId);
imageCreative.setDestinationUrl("http://google.com");
imageCreative.setSize(size);
// Create image asset.
CreativeAsset creativeAsset = new CreativeAsset();
creativeAsset.setFileName("image.jpg");
creativeAsset.setAssetByteArray(Media.getMediaDataFromUrl("https://goo.gl/3b9Wfh"));
creativeAsset.setSize(size);
imageCreative.setPrimaryImageAsset(creativeAsset);
// Create an image redirect creative.
ImageRedirectCreative imageRedirectCreative = new ImageRedirectCreative();
imageRedirectCreative.setName("Image redirect creative #" + new Random().nextInt(Integer.MAX_VALUE));
imageRedirectCreative.setAdvertiserId(advertiserId);
imageRedirectCreative.setDestinationUrl("http://google.com");
imageRedirectCreative.setImageUrl("https://goo.gl/3b9Wfh");
imageRedirectCreative.setSize(size);
// Create the creatives on the server.
Creative[] creatives = creativeService.createCreatives(new Creative[] { imageCreative, imageRedirectCreative });
for (Creative createdCreative : creatives) {
System.out.printf("A creative with ID %d, name '%s', and type '%s'" + " was created and can be previewed at: %s%n", createdCreative.getId(), createdCreative.getName(), createdCreative.getClass().getSimpleName(), createdCreative.getPreviewUrl());
}
}
use of com.google.api.ads.admanager.axis.v202205.ImageRedirectCreative in project googleads-java-lib by googleads.
the class CreateCreatives method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param advertiserId the ID of the advertiser (company) that all creatives will be assigned to.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
* @throws IOException if unable to get media data from the URL.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long advertiserId) throws IOException {
// Get the CreativeService.
CreativeServiceInterface creativeService = adManagerServices.get(session, CreativeServiceInterface.class);
// Create creative size.
Size size = new Size();
size.setWidth(600);
size.setHeight(315);
size.setIsAspectRatio(false);
// Create an image creative.
ImageCreative imageCreative = new ImageCreative();
imageCreative.setName("Image creative #" + new Random().nextInt(Integer.MAX_VALUE));
imageCreative.setAdvertiserId(advertiserId);
imageCreative.setDestinationUrl("http://google.com");
imageCreative.setSize(size);
// Create image asset.
CreativeAsset creativeAsset = new CreativeAsset();
creativeAsset.setFileName("image.jpg");
creativeAsset.setAssetByteArray(Media.getMediaDataFromUrl("https://goo.gl/3b9Wfh"));
creativeAsset.setSize(size);
imageCreative.setPrimaryImageAsset(creativeAsset);
// Create an image redirect creative.
ImageRedirectCreative imageRedirectCreative = new ImageRedirectCreative();
imageRedirectCreative.setName("Image redirect creative #" + new Random().nextInt(Integer.MAX_VALUE));
imageRedirectCreative.setAdvertiserId(advertiserId);
imageRedirectCreative.setDestinationUrl("http://google.com");
imageRedirectCreative.setImageUrl("https://goo.gl/3b9Wfh");
imageRedirectCreative.setSize(size);
// Create the creatives on the server.
Creative[] creatives = creativeService.createCreatives(new Creative[] { imageCreative, imageRedirectCreative });
for (Creative createdCreative : creatives) {
System.out.printf("A creative with ID %d, name '%s', and type '%s'" + " was created and can be previewed at: %s%n", createdCreative.getId(), createdCreative.getName(), createdCreative.getClass().getSimpleName(), createdCreative.getPreviewUrl());
}
}
Aggregations