Package com.google.api.ads.dfa.axis.v1_20

Examples of com.google.api.ads.dfa.axis.v1_20.CreativeRemote


  private static final String CREATIVE_ID = "INSERT_IN_STREAM_VIDEO_CREATIVE_ID_HERE";

  public static void runExample(DfaServices dfaServices, DfaSession session, long creativeId)
      throws Exception {
    // Request the creative service from the service client factory.
    CreativeRemote creativeService = dfaServices.get(session, CreativeRemote.class);

    // Fetch the In-Stream video creative which contains the asset to modify.
    CreativeBase rawCreative = creativeService.getCreative(creativeId);

    if (!(rawCreative instanceof InStreamVideoCreative)) {
      System.out.printf("Unable to update creative with ID \"%s\": not an In-Stream video "
          + "creative.", creativeId);
    } else {
      InStreamVideoCreative inStreamVideoCreative = (InStreamVideoCreative) rawCreative;

      // Modify the media files, companion ads, and/or non-linear ads.
      if (inStreamVideoCreative.getMediaFiles() != null) {
        for (InStreamMediaFile mediaFile : inStreamVideoCreative.getMediaFiles()) {
          mediaFile.setPickedToServe(!mediaFile.isPickedToServe());
        }
      }

      if (inStreamVideoCreative.getCompanionAds() != null) {
        for (InStreamCompanionAd companionAd : inStreamVideoCreative.getCompanionAds()) {
          companionAd.setAltText(companionAd.getAltText() + " Updated.");
        }
      }

      if (inStreamVideoCreative.getNonLinearAds() != null) {
        for (InStreamNonLinearAd nonLinearAd : inStreamVideoCreative.getNonLinearAds()) {
          nonLinearAd.setScalable(!nonLinearAd.isScalable());
        }
      }

      CreativeSaveResult creativeSaveResult =
          creativeService.saveCreative(inStreamVideoCreative, 0);

      System.out.printf("Updated the In-Stream assets of In-Stream video creative with ID "
          + "\"%s\".%n", creativeSaveResult.getId());
    }
  }
View Full Code Here


  public static void runExample(
      DfaServices dfaServices, DfaSession session, String assetName, String pathToFile,
      long advertiserId) throws Exception {
    // Request the service.
    CreativeRemote service = dfaServices.get(session, CreativeRemote.class);

    // Create the mobile asset.
    CreativeAsset mobileAsset = new CreativeAsset();
    mobileAsset.setName(assetName);
    mobileAsset.setContent(Media.getMediaDataFromFile(pathToFile));
    mobileAsset.setForHTMLCreatives(true);
    mobileAsset.setAdvertiserId(advertiserId);

    // Save the mobile asset.
    CreativeAssetSaveResult creativeAssetSaveResult = service.saveCreativeAsset(mobileAsset);

    // Display the new asset file name.
    System.out.printf("Asset was saved with file name of \"%s\".%n",
        creativeAssetSaveResult.getSavedFilename());
  }
View Full Code Here

      DfaServices dfaServices, DfaSession session, long advertiserId,
      float videoDuration, String adId, String surveyUrl,
      String clickThroughUrl, long campaignId) throws Exception {

    // Request the creative service from the service client factory.
    CreativeRemote creativeService = dfaServices.get(session, CreativeRemote.class);

    // Create the In-Stream video creative.
    InStreamVideoCreative inStreamVideoCreative = new InStreamVideoCreative();
    inStreamVideoCreative.setAdvertiserId(advertiserId);
    inStreamVideoCreative.setName("In-Stream Video Creative #" + System.currentTimeMillis());
    inStreamVideoCreative.setVideoDuration(videoDuration);
    // In-Stream video creatives have to be created inactive. One can only be
    // set active after at least one media file has been added to it or the API
    // will return an error message.
    inStreamVideoCreative.setActive(false);

    // Set the video details based on the Video Ad Serving Template (VAST)
    // specification.
    inStreamVideoCreative.setAdId(adId);
    inStreamVideoCreative.setDescription("You are viewing an In-Stream Video Creative");
    inStreamVideoCreative.setSurveyUrl(surveyUrl);
    inStreamVideoCreative.setClickThroughUrl(clickThroughUrl);

    // Save the In-Stream video creative.
    CreativeSaveResult creativeSaveResult = creativeService.saveCreative(inStreamVideoCreative,
        campaignId);

    // Display the new creative ID.
    System.out.printf("In-Stream video creative with ID \"%s\" was created.%n",
        creativeSaveResult.getId());
View Full Code Here

      DfaServices dfaServices, DfaSession session, String advertiserGroupName) throws Exception {
    // Request the service.
    AdvertiserGroupRemote service = dfaServices.get(session, AdvertiserGroupRemote.class);

    // Create advertiser group structure.
    AdvertiserGroup advertiserGroup = new AdvertiserGroup();
    advertiserGroup.setId(0);
    advertiserGroup.setName(advertiserGroupName);

    // Create advertiser group.
    AdvertiserGroupSaveResult advertiserGroupSaveResult =
        service.saveAdvertiserGroup(advertiserGroup);
View Full Code Here

    AdvertiserGroupSearchCriteria advGroupSearchCriteria = new AdvertiserGroupSearchCriteria();
    advGroupSearchCriteria.setPageSize(10);
    advGroupSearchCriteria.setSearchString(searchString);

    // Get advertiser group record set.
    AdvertiserGroupRecordSet advertiserGroupRecordSet =
        service.getAdvertiserGroups(advGroupSearchCriteria);

    // Display advertiser group names, IDs and advertiser count.
    if (advertiserGroupRecordSet.getRecords() != null) {
      for (AdvertiserGroup result : advertiserGroupRecordSet.getRecords()) {
        System.out.println("Advertiser Group with name \"" + result.getName()
            + "\", ID \"" + result.getId()
            + "\", containing " + result.getAdvertiserCount()
            + " advertisers was found.");
      }
View Full Code Here

  private static final String SEARCH_STRING = "INSERT_SEARCH_CRITERIA_HERE";

  public static void runExample(
      DfaServices dfaServices, DfaSession session, String searchString) throws Exception {
    // Request the service.
    AdvertiserGroupRemote service = dfaServices.get(session, AdvertiserGroupRemote.class);

    // Create advertiser group search criteria structure.
    AdvertiserGroupSearchCriteria advGroupSearchCriteria = new AdvertiserGroupSearchCriteria();
    advGroupSearchCriteria.setPageSize(10);
    advGroupSearchCriteria.setSearchString(searchString);

    // Get advertiser group record set.
    AdvertiserGroupRecordSet advertiserGroupRecordSet =
        service.getAdvertiserGroups(advGroupSearchCriteria);

    // Display advertiser group names, IDs and advertiser count.
    if (advertiserGroupRecordSet.getRecords() != null) {
      for (AdvertiserGroup result : advertiserGroupRecordSet.getRecords()) {
        System.out.println("Advertiser Group with name \"" + result.getName()
View Full Code Here

  private static final String ADVERTISER_GROUP_NAME = "INSERT_ADVERTISER_GROUP_NAME_HERE";

  public static void runExample(
      DfaServices dfaServices, DfaSession session, String advertiserGroupName) throws Exception {
    // Request the service.
    AdvertiserGroupRemote service = dfaServices.get(session, AdvertiserGroupRemote.class);

    // Create advertiser group structure.
    AdvertiserGroup advertiserGroup = new AdvertiserGroup();
    advertiserGroup.setId(0);
    advertiserGroup.setName(advertiserGroupName);

    // Create advertiser group.
    AdvertiserGroupSaveResult advertiserGroupSaveResult =
        service.saveAdvertiserGroup(advertiserGroup);

    // Display advertiser group ID.
    System.out.printf("Advertiser Group with ID \"%s\" was created.",
        advertiserGroupSaveResult.getId());
  }
View Full Code Here

    AdvertiserGroup advertiserGroup = new AdvertiserGroup();
    advertiserGroup.setId(0);
    advertiserGroup.setName(advertiserGroupName);

    // Create advertiser group.
    AdvertiserGroupSaveResult advertiserGroupSaveResult =
        service.saveAdvertiserGroup(advertiserGroup);

    // Display advertiser group ID.
    System.out.printf("Advertiser Group with ID \"%s\" was created.",
        advertiserGroupSaveResult.getId());
  }
View Full Code Here

      DfaServices dfaServices, DfaSession session, String searchString) throws Exception {
    // Request the service.
    AdvertiserGroupRemote service = dfaServices.get(session, AdvertiserGroupRemote.class);

    // Create advertiser group search criteria structure.
    AdvertiserGroupSearchCriteria advGroupSearchCriteria = new AdvertiserGroupSearchCriteria();
    advGroupSearchCriteria.setPageSize(10);
    advGroupSearchCriteria.setSearchString(searchString);

    // Get advertiser group record set.
    AdvertiserGroupRecordSet advertiserGroupRecordSet =
        service.getAdvertiserGroups(advGroupSearchCriteria);
View Full Code Here

    AdvertiserSearchCriteria advSearchCriteria = new AdvertiserSearchCriteria();
    advSearchCriteria.setPageSize(100);
    // When paging, start counting page numbers from 1 rather than 0.
    advSearchCriteria.setPageNumber(1);

    AdvertiserRecordSet advertiserRecordSet;
    int i = 1;

    do {
      // Get advertisers by criteria.
      advertiserRecordSet = advertiserService.getAdvertisers(
          advSearchCriteria);

      for (Advertiser result : advertiserRecordSet.getRecords()) {
        System.out.printf("%s) Advertiser with name \"%s\", ID \"%s\", and spotlight " +
            "configuration ID \"%s\" was found.%n", i++, result.getName(), result.getId(),
            result.getSpotId());
      }

      advSearchCriteria.setPageNumber(advSearchCriteria.getPageNumber() + 1);
    } while (advSearchCriteria.getPageNumber() <= advertiserRecordSet.getTotalNumberOfPages());

    System.out.printf("Number of results found: %s%n",
        advertiserRecordSet.getTotalNumberOfRecords());
  }
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfa.axis.v1_20.CreativeRemote

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.