Package com.google.api.adwords.v201306.cm

Examples of com.google.api.adwords.v201306.cm.AuthenticationError


      // Create campaign.
      Campaign goodCampaign = new Campaign();
      goodCampaign.setName("Campaign #" + System.currentTimeMillis());
      goodCampaign.setStatus(CampaignStatus.PAUSED);
      BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
      ManualCpcBiddingScheme manualCpc = new ManualCpcBiddingScheme();
      manualCpc.setEnhancedCpcEnabled(false);
      biddingConfig.setBiddingScheme(manualCpc);
      goodCampaign.setBiddingStrategyConfiguration(biddingConfig);

      // Create budget.
      Budget budget = new Budget();
View Full Code Here


      Predicate typePredicate =
          new Predicate("Type", PredicateOperator.IN, new String[] {"VIDEO"});
      selector.setPredicates(new Predicate[] {typePredicate});

      // Get all videos.
      MediaPage page = mediaService.get(selector);

      // Display videos.
      if (page.getEntries() != null) {
        for (Media video : page.getEntries()) {
          System.out.println("Video with id '" + video.getMediaId()
              + "' and name '" + video.getName() + "' was found.");
        }
      } else {
        System.out.println("No videos were found.");
View Full Code Here

      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the MediaService.
      MediaServiceInterface mediaService =
          user.getService(AdWordsService.V201306.MEDIA_SERVICE);

      // Create image.
      Image image = new Image();
      image.setData(ImageUtils.getImageDataFromUrl("http://goo.gl/HJM3L"));
      image.setType(MediaMediaType.IMAGE);

      Media[] media = new Media[] {image};

      // Upload image.
      Media[] result = mediaService.upload(media);

      // Display images.
      if (result != null) {
        image = (Image) result[0];
        Map<MediaSize, Dimensions> dimensions = MapUtils.toMap(image.getDimensions());
View Full Code Here

      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the MediaService.
      MediaServiceInterface mediaService =
          user.getService(AdWordsService.V201306.MEDIA_SERVICE);

      // Create selector.
      Selector selector = new Selector();
      selector.setFields(new String[] {"MediaId", "Name"});
      selector.setOrdering(new OrderBy[] {new OrderBy("MediaId", SortOrder.ASCENDING)});

      // Create predicates.
      Predicate typePredicate =
          new Predicate("Type", PredicateOperator.IN, new String[] {"VIDEO"});
      selector.setPredicates(new Predicate[] {typePredicate});

      // Get all videos.
      MediaPage page = mediaService.get(selector);

      // Display videos.
      if (page.getEntries() != null) {
        for (Media video : page.getEntries()) {
          System.out.println("Video with id '" + video.getMediaId()
View Full Code Here

      List<AdGroupEstimateRequest> adGroupEstimateRequests =
          new ArrayList<AdGroupEstimateRequest>();
      AdGroupEstimateRequest adGroupEstimateRequest = new AdGroupEstimateRequest();
      adGroupEstimateRequest.setKeywordEstimateRequests(
          keywordEstimateRequests.toArray(new KeywordEstimateRequest[]{}));
      adGroupEstimateRequest.setMaxCpc(new Money(null, 1000000L));
      adGroupEstimateRequests.add(adGroupEstimateRequest);

      // Create campaign estimate requests.
      List<CampaignEstimateRequest> campaignEstimateRequests =
        new ArrayList<CampaignEstimateRequest>();
View Full Code Here

      goodCampaign.setBiddingStrategyConfiguration(biddingConfig);

      // Create budget.
      Budget budget = new Budget();
      budget.setPeriod(BudgetBudgetPeriod.DAILY);
      budget.setAmount(new Money(null, 50000000L));
      budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
      goodCampaign.setBudget(budget);

      KeywordMatchSetting keywordMatch = new KeywordMatchSetting();
      keywordMatch.setOptIn(Boolean.TRUE);
View Full Code Here

      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the MutateJobService.
      MutateJobServiceInterface mutateJobService =
          user.getService(AdWordsService.V201306.MUTATE_JOB_SERVICE);

      long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");

      Random r = new Random();
      List<AdGroupCriterionOperation> operations = new ArrayList<AdGroupCriterionOperation>();

      // Create AdGroupCriterionOperations to add keywords.
      for (int i = 0; i < KEYWORD_NUMBER; i++) {
        // Create Keyword.
        String text = String.format("mars%d", i);
        if (r.nextInt() % 10 == 0) {
          text = text + "!!!";
        }
        Keyword keyword = new Keyword();
        keyword.setText(text);
        keyword.setMatchType(KeywordMatchType.BROAD);
        // Create BiddableAdGroupCriterion.
        BiddableAdGroupCriterion bagc = new BiddableAdGroupCriterion();
        bagc.setAdGroupId(adGroupId);
        bagc.setCriterion(keyword);
        // Create AdGroupCriterionOperation.
        AdGroupCriterionOperation agco = new AdGroupCriterionOperation();
        agco.setOperand(bagc);
        agco.setOperator(Operator.ADD);
        // Add to list.
        operations.add(agco);
      }

      // You can specify up to 3 job IDs that must successfully complete before
      // this job can be processed.
      BulkMutateJobPolicy policy = new BulkMutateJobPolicy();
      policy.setPrerequisiteJobIds(new long[] {});

      // Call mutate to create a new job.
      SimpleMutateJob response =
          mutateJobService.mutate(operations.toArray(new Operation[operations.size()]), policy);

      long jobId = response.getId();
      System.out.printf("Job with ID %d was successfully created.\n", jobId);

      // Create selector to retrieve job status and wait for it to complete.
      BulkMutateJobSelector selector = new BulkMutateJobSelector();
      selector.setJobIds(new long[] {jobId});

      // Poll for job status until it's finished.
      System.out.println("Retrieving job status...");
      SimpleMutateJob jobStatusResponse = null;
      BasicJobStatus status = null;
      for (int i = 0; i < RETRIES_COUNT; i++) {
        Job[] jobs = mutateJobService.get(selector);
        jobStatusResponse = (SimpleMutateJob) jobs[0];
        status = jobStatusResponse.getStatus();
        if (status == BasicJobStatus.COMPLETED || status == BasicJobStatus.FAILED) {
          break;
        }
        System.out.printf("[%d] Current status is '%s', waiting %d seconds to retry...\n", i,
            status.toString(), RETRY_INTERVAL);
        Thread.sleep(RETRY_INTERVAL * 1000);
      }

      // Handle unsuccessful results.
      if (status == BasicJobStatus.FAILED) {
        throw new IllegalStateException("Job failed with reason: "
            + jobStatusResponse.getFailureReason());
      }
      if (status == BasicJobStatus.PENDING || status == BasicJobStatus.PROCESSING) {
        throw new IllegalAccessException("Job did not complete within "
            + ((RETRIES_COUNT - 1) * RETRY_INTERVAL) + " seconds.");
      }

      // Status must be COMPLETED.
      // Get the job result. Here we re-use the same selector.
      JobResult result = mutateJobService.getResult(selector);

      // Output results.
      int i = 0;
      for (Operand operand : result.getSimpleMutateResult().getResults()) {
        String outcome = operand.getPlaceHolder() == null ? "SUCCESS" : "FAILED";
View Full Code Here

      Keyword keyword = new Keyword();
      keyword.setText("jupiter cruise");
      keyword.setMatchType(KeywordMatchType.BROAD);

      // Create negative campaign criterion.
      NegativeCampaignCriterion negativeCampaignCriterion = new NegativeCampaignCriterion();
      negativeCampaignCriterion.setCampaignId(campaignId);
      negativeCampaignCriterion.setCriterion(keyword);

      // Create operations.
      CampaignCriterionOperation operation = new CampaignCriterionOperation();
      operation.setOperand(negativeCampaignCriterion);
      operation.setOperator(Operator.ADD);
View Full Code Here

      Long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");

      // Create selector.
      Selector selector = new Selector();
      selector.setFields(new String[] {"Id", "AdGroupId", "Status"});
      selector.setOrdering(new OrderBy[] {new OrderBy("Id", SortOrder.ASCENDING)});

      // Create predicates.
      Predicate statusPredicate =
          new Predicate("Status", PredicateOperator.IN, new String[] {"ACTIVE"});
      Predicate adGroupIdPredicate =
View Full Code Here

          user.getService(AdWordsService.V201306.MEDIA_SERVICE);

      // Create selector.
      Selector selector = new Selector();
      selector.setFields(new String[] {"MediaId", "Name"});
      selector.setOrdering(new OrderBy[] {new OrderBy("MediaId", SortOrder.ASCENDING)});

      // Create predicates.
      Predicate typePredicate =
          new Predicate("Type", PredicateOperator.IN, new String[] {"VIDEO"});
      selector.setPredicates(new Predicate[] {typePredicate});
View Full Code Here

TOP

Related Classes of com.google.api.adwords.v201306.cm.AuthenticationError

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.