Package com.google.api.ads.dfp.v201302

Examples of com.google.api.ads.dfp.v201302.Date


      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the CreativeService.
      CreativeServiceInterface creativeService =
          user.getService(DfpService.V201302.CREATIVE_SERVICE);

      // Set the ID of the advertiser (company) that all creative will be
      // assigned to.
      Long advertiserId = Long.parseLong("INSERT_ADVERTISER_COMPANY_ID_HERE");

      // Use the image banner with optional third party tracking template.
      Long creativeTemplateId = 10000680L;

      // Create the local custom creative object.
      TemplateCreative templateCreative = new TemplateCreative();
      templateCreative.setName("Template creative");
      templateCreative.setAdvertiserId(advertiserId);
      templateCreative.setCreativeTemplateId(creativeTemplateId);

      // Set the creative size.
      templateCreative.setSize(new Size(300, 250, false));

      // Create the asset variable value.
      AssetCreativeTemplateVariableValue assetVariableValue =
          new AssetCreativeTemplateVariableValue();
      assetVariableValue.setUniqueName("Imagefile");
      assetVariableValue.setAssetByteArray(MediaUtils.getAssetDataFromUrl(
          "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg"));
      // Filenames must be unique.
      assetVariableValue.setFileName(String.format("image%s.jpg", System.currentTimeMillis()));

      // Create the image width variable value.
      LongCreativeTemplateVariableValue imageWidthVariableValue =
          new LongCreativeTemplateVariableValue();
      imageWidthVariableValue.setUniqueName("Imagewidth");
      imageWidthVariableValue.setValue(300L);

      // Create the image height variable value.
      LongCreativeTemplateVariableValue imageHeightVariableValue =
          new LongCreativeTemplateVariableValue();
      imageHeightVariableValue.setUniqueName("Imageheight");
      imageHeightVariableValue.setValue(250L);

      // Create the URL variable value.
      UrlCreativeTemplateVariableValue urlVariableValue =
          new UrlCreativeTemplateVariableValue();
      urlVariableValue.setUniqueName("ClickthroughURL");
      urlVariableValue.setValue("www.google.com");

      // Create the target window variable value.
      StringCreativeTemplateVariableValue targetWindowVariableValue =
          new StringCreativeTemplateVariableValue();
      targetWindowVariableValue.setUniqueName("Targetwindow");
      targetWindowVariableValue.setValue("__blank");

      templateCreative.setCreativeTemplateVariableValues(new BaseCreativeTemplateVariableValue[] {
          assetVariableValue, imageWidthVariableValue, imageHeightVariableValue, urlVariableValue,
          targetWindowVariableValue});

      // Create the template creative on the server.
      templateCreative = (TemplateCreative) creativeService.createCreative(templateCreative);

      if (templateCreative != null) {
        System.out.println("A template creative with ID \"" + templateCreative.getId()
            + "\", name \"" + templateCreative.getName() + "\", and type \""
            + templateCreative.getCreativeType() + "\" was created and\n"
View Full Code Here


      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the CreativeService.
      CreativeServiceInterface creativeService =
          user.getService(DfpService.V201302.CREATIVE_SERVICE);

      // Set defaults for page and filterStatement.
      CreativePage page = new CreativePage();
      Statement filterStatement = new Statement();
      int offset = 0;

      do {
        // Create a statement to get all creatives.
        filterStatement.setQuery("LIMIT 500 OFFSET " + offset);

        // Get creatives by statement.
        page = creativeService.getCreativesByStatement(filterStatement);

        if (page.getResults() != null) {
          int i = page.getStartIndex();
          for (Creative creative : page.getResults()) {
            System.out.println(i + ") Creative with ID \"" + creative.getId()
View Full Code Here

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the CreativeService.
      CreativeServiceInterface creativeService =
          user.getService(DfpService.V201302.CREATIVE_SERVICE);

      // Set the ID of the creative to get.
      Long creativeId = Long.parseLong("INSERT_CREATIVE_ID_HERE");

      // Get the creative.
      Creative creative = creativeService.getCreative(creativeId);

      if (creative != null) {
        System.out.println("Creative with ID \"" + creative.getId()
             + "\", name \"" + creative.getName()
             + "\", and type \"" + creative.getCreativeType() + "\" was found.");
View Full Code Here

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the CreativeService.
      CreativeServiceInterface creativeService =
          user.getService(DfpService.V201302.CREATIVE_SERVICE);

      // Set the ID of the advertiser (company) that all creatives will be
      // assigned to.
      Long advertiserId = Long.parseLong("INSERT_ADVERTISER_COMPANY_ID_HERE");

      // Create an array to store local image creative objects.
      Creative[] imageCreatives = new ImageCreative[5];

      for (int i = 0; i < 5; i++) {
        // Create creative size.
        Size size = new Size();
        size.setWidth(300);
        size.setHeight(250);
        size.setIsAspectRatio(false);

        // Create an image creative.
        ImageCreative imageCreative = new ImageCreative();
        imageCreative.setName("Image creative #" + i);
        imageCreative.setAdvertiserId(advertiserId);
        imageCreative.setDestinationUrl("http://google.com");
        imageCreative.setSize(size);

        // Create image asset.
        CreativeAsset creativeAsset = new CreativeAsset();
        creativeAsset.setFileName("image.jpg");
        creativeAsset.setAssetByteArray(MediaUtils.getAssetDataFromUrl(
            "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg"));
        creativeAsset.setSize(size);
        imageCreative.setPrimaryImageAsset(creativeAsset);

        imageCreatives[i] = imageCreative;
      }

      // Create the image creatives on the server.
      imageCreatives = creativeService.createCreatives(imageCreatives);

      if (imageCreatives != null) {
        for (Creative creative : imageCreatives) {
          // Use instanceof to determine what type of creative was returned.
          if (creative instanceof ImageCreative) {
View Full Code Here

      // Set the ID of the advertiser (company) that all creatives will be
      // assigned to.
      Long advertiserId = Long.parseLong("INSERT_ADVERTISER_COMPANY_ID_HERE");

      // Create the local custom creative object.
      CustomCreative customCreative = new CustomCreative();
      customCreative.setName("Custom creative");
      customCreative.setAdvertiserId(advertiserId);
      customCreative.setDestinationUrl("http://google.com");

      // Set the custom creative image asset.
      CustomCreativeAsset customCreativeAsset = new CustomCreativeAsset();
      customCreativeAsset.setMacroName("IMAGE_ASSET");
      customCreativeAsset.setAssetByteArray(MediaUtils.getAssetDataFromUrl(
          "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg"));
      // Filenames must be unique.
      customCreativeAsset.setFileName(String.format("image%s.jpg", System.currentTimeMillis()));
      customCreative.setCustomCreativeAssets(new CustomCreativeAsset[] {customCreativeAsset});

      // Set the HTML snippet using the custom creative asset macro.
      customCreative.setHtmlSnippet("<a href='%%CLICK_URL_UNESC%%%%DEST_URL%%'>" +
          "<img src='%%FILE:" + customCreativeAsset.getMacroName() + "%%'/>" +
          "</a><br>Click above for great deals!");

      // Set the creative size.
      customCreative.setSize(new Size(300, 250, false));

      // Create the custom creative on the server.
      customCreative = (CustomCreative) creativeService.createCreative(customCreative);

      if (customCreative != null) {
        System.out.println("A custom creative with ID \"" + customCreative.getId()
            + "\", name \"" + customCreative.getName()
            + "\", and size {" + customCreative.getSize().getWidth()
            + ", " + customCreative.getSize().getHeight() + "} was created and\n"
            + " can be previewed at: " + customCreative.getPreviewUrl());
      } else {
        System.out.println("No creative created.");
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

      customCreative.setName("Custom creative");
      customCreative.setAdvertiserId(advertiserId);
      customCreative.setDestinationUrl("http://google.com");

      // Set the custom creative image asset.
      CustomCreativeAsset customCreativeAsset = new CustomCreativeAsset();
      customCreativeAsset.setMacroName("IMAGE_ASSET");
      customCreativeAsset.setAssetByteArray(MediaUtils.getAssetDataFromUrl(
          "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg"));
      // Filenames must be unique.
      customCreativeAsset.setFileName(String.format("image%s.jpg", System.currentTimeMillis()));
      customCreative.setCustomCreativeAssets(new CustomCreativeAsset[] {customCreativeAsset});

      // Set the HTML snippet using the custom creative asset macro.
      customCreative.setHtmlSnippet("<a href='%%CLICK_URL_UNESC%%%%DEST_URL%%'>" +
          "<img src='%%FILE:" + customCreativeAsset.getMacroName() + "%%'/>" +
          "</a><br>Click above for great deals!");

      // Set the creative size.
      customCreative.setSize(new Size(300, 250, false));
View Full Code Here

          new StatementBuilder(statementText)
              .putValue("entityType", CustomFieldEntityType.LINE_ITEM.toString())
              .toStatement();

      // Set defaults for page and offset.
      CustomFieldPage page = new CustomFieldPage();
      int offset = 0;
      int i = 0;
      List<Long> customFieldIds = new ArrayList<Long>();

      do {
        // Create a statement to page through custom fields.
        filterStatement.setQuery(statementText + " OFFSET " + offset);

        // Get custom fields by statement.
        page = customFieldService.getCustomFieldsByStatement(filterStatement);

        if (page.getResults() != null) {
          for (CustomField customField : page.getResults()) {
            System.out.println(i + ") Custom field with ID \""
                + customField.getId() + "\" and name \"" + customField.getName()
                + "\" was found.");
            customFieldIds.add(customField.getId());
            i++;
          }
        }

        offset += 500;
      } while (offset < page.getTotalResultSetSize());

      System.out.println("Number of results found: " + page.getTotalResultSetSize());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

      // Get DfpUser from "~/dfp.properties".
      DfpUser user = new DfpUser();

      // Get the CustomFieldService.
      CustomFieldServiceInterface customFieldService =
          user.getService(DfpService.V201302.CUSTOM_FIELD_SERVICE);

      // Create statement to select only custom fields that apply to line items.
      String statementText =
          "WHERE entityType = :entityType LIMIT 500";
      Statement filterStatement =
          new StatementBuilder(statementText)
              .putValue("entityType", CustomFieldEntityType.LINE_ITEM.toString())
              .toStatement();

      // Set defaults for page and offset.
      CustomFieldPage page = new CustomFieldPage();
      int offset = 0;
      int i = 0;
      List<Long> customFieldIds = new ArrayList<Long>();

      do {
        // Create a statement to page through custom fields.
        filterStatement.setQuery(statementText + " OFFSET " + offset);

        // Get custom fields by statement.
        page = customFieldService.getCustomFieldsByStatement(filterStatement);

        if (page.getResults() != null) {
          for (CustomField customField : page.getResults()) {
            System.out.println(i + ") Custom field with ID \""
                + customField.getId() + "\" and name \"" + customField.getName()
View Full Code Here

   */
  public static Date fromDate(java.util.Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);

    Date dfpDate = new Date();
    dfpDate.setYear(calendar.get(Calendar.YEAR));
    dfpDate.setMonth(calendar.get(Calendar.MONTH) + 1);
    dfpDate.setDay(calendar.get(Calendar.DAY_OF_MONTH));

    return dfpDate;
  }
View Full Code Here

   * @param date the DFP {@code Date} object to convert to a Java {@code Date}
   * @param timeZoneId the timezone of the date
   * @return the DFP {@code Date} object as a Java {@code Date} in the timezone
   */
  public static java.util.Date toDate(Date date, String timeZoneId) {
    return DateTimeUtils.toDate(new DateTime(date, 0, 0, 0, timeZoneId));
  }
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.v201302.Date

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.