Package com.google.api.adwords.lib

Examples of com.google.api.adwords.lib.AdWordsUser


    try {
      // Log SOAP XML request and response.
      AdWordsServiceLogger.log();

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

      // Get the CampaignService.
      ManagedCustomerServiceInterface managedCustomerService =
          user.getService(AdWordsService.V201306.MANAGED_CUSTOMER_SERVICE);

      // Create account.
      ManagedCustomer customer = new ManagedCustomer();
      customer.setName("Customer created by ManagedCustomerService #" + System.currentTimeMillis());
      customer.setCurrencyCode("EUR");
View Full Code Here


    AuthToken authToken = new AuthToken(email, password);

    // Get AdWordsUser from "~/adwords.properties". In the properties file,
    // you will only need to set the developerToken, useragent, or clientId (if
    // needed).
    AdWordsUser user = new AdWordsUser();

    // Uncomment to cause a CAPTCHA required failure.
    // causeCaptchaError(authToken);

    String authTokenString = "";

    // Handle CAPTCHA error.
    try {
      // Get auth token string.
      authTokenString = authToken.getAuthToken();
    } catch (AuthTokenException e) {
      if (e.getErrorCode() != null && e.getErrorCode().equals("CaptchaRequired")) {
        // Try getting the auth token again but with a captcha.
        System.out.println("Go here and read the captcha: " + e.getCaptchaInfo().getCaptchaUrl());
        System.out.print("Answer is: ");
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String answer = in.readLine().trim();
        authTokenString =
            new AuthToken(authToken, e.getCaptchaInfo().getCaptchaToken(), answer).getAuthToken();
      } else {
        throw e;
      }
    }


    // Set the auth token in the user so that it will not be generated when
    // user.getService() is called.
    user.setAuthToken(authTokenString);

    // Handle possible token expiration. You can cause an expiration by
    // pausing this code and changing the password of the account before the
    // first makeApiRequest() is called. If you do so, change your password back
    // before you regenerate the auth token again.
    try {
      makeApiRequest(user);
    } catch (ApiException e) {
      for (ApiError error : e.getErrors()) {
        if (error instanceof AuthenticationError) {
          AuthenticationError authError = (AuthenticationError) error;
          if (authError.getReason() == AuthenticationErrorReason.GOOGLE_ACCOUNT_COOKIE_INVALID) {
            // Try to regenerate auth token here again in case it expired.
            user.setAuthToken(authToken.getAuthToken());
            makeApiRequest(user);
          } else {
            System.err.println("Service call failed for authentication reason: "
                + authError.getReason());
          }
View Full Code Here

    try {
      // Log SOAP XML request and response.
      AdWordsServiceLogger.log();

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

      // Set partial failure flag.
      user.setUsePartialFailure(true);

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201309.ADGROUP_CRITERION_SERVICE);

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

      List<AdGroupCriterionOperation> operations = new ArrayList<AdGroupCriterionOperation>();
View Full Code Here

    try {
      // Log SOAP XML request and response.
      AdWordsServiceLogger.log();

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

      // Get the AdGroupAdService.
      AdGroupAdServiceInterface adGroupAdService =
          user.getService(AdWordsService.V201306.ADGROUP_AD_SERVICE);

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

      // Create selector.
      Selector selector = new Selector();
View Full Code Here

  public static void main(String args[]) throws Exception {
    // Log SOAP XML request and response.
    AdWordsServiceLogger.log();

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

    // Get v13 traffic estimator service.
    TrafficEstimatorInterface trafficEstimatorService =
        user.getService(AdWordsService.V13.TRAFFIC_ESTIMATOR_SERVICE);

    // Get v200909 AdGroupCriterionService.
    AdGroupCriterionServiceInterface adGroupCriterionService =
        user.getService(AdWordsService.V200909.ADGROUP_CRITERION_SERVICE);

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

    // Create selector to get all criteria under ad group.
    AdGroupCriterionSelector selector = new AdGroupCriterionSelector();
View Full Code Here

    try {
      // Log SOAP XML request and response.
      AdWordsServiceLogger.log();

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

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201306.ADGROUP_CRITERION_SERVICE);

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

      // Create keyword.
      Keyword keyword = new Keyword();
View Full Code Here

    try {
      // Log SOAP XML request and response.
      AdWordsServiceLogger.log();

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

      // Get the CampaignService.
      ManagedCustomerServiceInterface managedCustomerService =
          user.getService(AdWordsService.V201309.MANAGED_CUSTOMER_SERVICE);

      // Create account.
      ManagedCustomer customer = new ManagedCustomer();
      customer.setName("Customer created by ManagedCustomerService #" + System.currentTimeMillis());
      customer.setCurrencyCode("EUR");
View Full Code Here

    try {
      // Log SOAP XML request and response.
      AdWordsServiceLogger.log();

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

      // Get the AdGroupAdService.
      AdGroupAdServiceInterface adGroupAdService =
          user.getService(AdWordsService.V201309.ADGROUP_AD_SERVICE);

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

      // Create selector.
      Selector selector = new Selector();
View Full Code Here

    // Log SOAP XML request and response.
    AdWordsServiceLogger.log();

    // Get AdWordsUser from "~/adwords.properties".
    AdWordsUser user = new AdWordsUser();
    runExample(user, campaignIds);
  }
View Full Code Here

    try {
      // Log SOAP XML request and response.
      AdWordsServiceLogger.log();

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

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201309.ADGROUP_CRITERION_SERVICE);

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

      // Create keyword.
      Keyword keyword = new Keyword();
View Full Code Here

TOP

Related Classes of com.google.api.adwords.lib.AdWordsUser

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.