google-adwords-api 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/README +2 -1
- data/examples/v201109/account_management/create_account.rb +2 -2
- data/examples/v201109/account_management/get_account_alerts.rb +3 -3
- data/examples/v201109/account_management/get_account_changes.rb +2 -2
- data/examples/v201109/account_management/get_account_hierarchy.rb +2 -2
- data/examples/v201109/account_management/get_client_customer_id.rb +6 -8
- data/examples/v201109/account_management/get_client_unit_usage.rb +6 -7
- data/examples/v201109/basic_operations/add_ad_groups.rb +111 -0
- data/examples/v201109/basic_operations/add_campaigns.rb +125 -0
- data/examples/v201109/basic_operations/add_keywords.rb +16 -11
- data/examples/v201109/basic_operations/add_text_ads.rb +23 -19
- data/examples/v201109/basic_operations/delete_ad.rb +7 -7
- data/examples/v201109/basic_operations/delete_ad_group.rb +7 -7
- data/examples/v201109/basic_operations/delete_campaign.rb +7 -7
- data/examples/v201109/basic_operations/delete_keyword.rb +7 -7
- data/examples/v201109/basic_operations/get_ad_groups.rb +7 -7
- data/examples/v201109/basic_operations/get_campaigns.rb +3 -3
- data/examples/v201109/basic_operations/get_keywords.rb +7 -7
- data/examples/v201109/basic_operations/get_text_ads.rb +7 -7
- data/examples/v201109/basic_operations/pause_ad.rb +7 -7
- data/examples/v201109/basic_operations/update_ad_group.rb +6 -6
- data/examples/v201109/basic_operations/update_campaign.rb +6 -6
- data/examples/v201109/basic_operations/update_keyword.rb +7 -7
- data/examples/v201109/campaign_management/add_experiment.rb +14 -9
- data/examples/v201109/campaign_management/add_keywords_in_bulk.rb +5 -5
- data/examples/v201109/campaign_management/add_location_extension.rb +13 -7
- data/examples/v201109/campaign_management/add_location_extension_override.rb +7 -7
- data/examples/v201109/campaign_management/get_all_disapproved_ads.rb +6 -6
- data/examples/v201109/campaign_management/promote_experiment.rb +5 -6
- data/examples/v201109/campaign_management/set_ad_parameters.rb +8 -8
- data/examples/v201109/campaign_management/validate_text_ad.rb +7 -9
- data/examples/v201109/error_handling/handle_captcha_challenge.rb +3 -4
- data/examples/v201109/error_handling/handle_partial_failures.rb +5 -6
- data/examples/v201109/error_handling/handle_policy_violation_error.rb +5 -6
- data/examples/v201109/error_handling/handle_two_factor_authorization_error.rb +2 -2
- data/examples/v201109/misc/get_all_images_and_videos.rb +3 -3
- data/examples/v201109/misc/upload_image.rb +2 -2
- data/examples/v201109/misc/use_oauth.rb +3 -3
- data/examples/v201109/optimization/estimate_keyword_traffic.rb +2 -2
- data/examples/v201109/optimization/get_keyword_bid_simulations.rb +6 -7
- data/examples/v201109/optimization/get_keyword_ideas.rb +6 -7
- data/examples/v201109/optimization/get_placement_ideas.rb +6 -7
- data/examples/v201109/remarketing/add_audience.rb +5 -3
- data/examples/v201109/remarketing/add_conversion_tracker.rb +12 -3
- data/examples/v201109/reporting/download_criteria_report.rb +7 -8
- data/examples/v201109/reporting/download_defined_report.rb +6 -7
- data/examples/v201109/reporting/get_campaign_stats.rb +105 -0
- data/examples/v201109/reporting/get_defined_reports.rb +2 -2
- data/examples/v201109/reporting/get_report_fields.rb +6 -7
- data/examples/v201109/reporting/parallel_report_download.rb +8 -8
- data/examples/v201109/targeting/add_campaign_targeting_criteria.rb +5 -6
- data/examples/v201109/targeting/get_campaign_targeting_criteria.rb +7 -8
- data/examples/v201109/targeting/get_targetable_languages_and_carriers.rb +2 -2
- data/examples/v201109/targeting/lookup_location.rb +2 -2
- data/lib/adwords_api/version.rb +1 -1
- data/test/examples/v201109/test_account_management.rb +60 -0
- data/test/examples/v201109/test_basic_operations.rb +172 -0
- data/test/examples/v201109/test_campaign_management.rb +116 -0
- data/test/examples/v201109/test_error_handling.rb +63 -0
- data/test/examples/v201109/test_misc.rb +45 -0
- data/test/examples/v201109/test_optimization.rb +63 -0
- data/test/examples/v201109/test_remarketing.rb +39 -0
- data/test/examples/v201109/test_reporting.rb +89 -0
- data/test/examples/v201109/test_targeting.rb +60 -0
- data/test/examples/v201109/utils.rb +239 -0
- data/test/suite_exampletests.rb +31 -0
- metadata +18 -6
- data/examples/v201109/basic_operations/add_ad_group.rb +0 -89
- data/examples/v201109/basic_operations/add_campaign.rb +0 -99
@@ -25,9 +25,7 @@
|
|
25
25
|
|
26
26
|
require 'adwords_api'
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
def update_keyword()
|
28
|
+
def update_keyword(ad_group_id, criterion_id)
|
31
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
32
30
|
# when called without parameters.
|
33
31
|
adwords = AdwordsApi::Api.new
|
@@ -39,9 +37,6 @@ def update_keyword()
|
|
39
37
|
ad_group_criterion_srv =
|
40
38
|
adwords.service(:AdGroupCriterionService, API_VERSION)
|
41
39
|
|
42
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
43
|
-
criterion_id = 'INSERT_CRITERION_ID_HERE'.to_i
|
44
|
-
|
45
40
|
# Prepare for updating a keyword.
|
46
41
|
operation = {
|
47
42
|
:operator => 'SET',
|
@@ -78,8 +73,13 @@ def update_keyword()
|
|
78
73
|
end
|
79
74
|
|
80
75
|
if __FILE__ == $0
|
76
|
+
API_VERSION = :v201109
|
77
|
+
|
81
78
|
begin
|
82
|
-
|
79
|
+
# IDs of a criterion to update and its ad group.
|
80
|
+
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
81
|
+
criterion_id = 'INSERT_CRITERION_ID_HERE'.to_i
|
82
|
+
update_keyword(ad_group_id, criterion_id)
|
83
83
|
|
84
84
|
# HTTP errors.
|
85
85
|
rescue AdsCommon::Errors::HttpError => e
|
@@ -27,10 +27,9 @@
|
|
27
27
|
# Tags: ExperimentService.mutate
|
28
28
|
|
29
29
|
require 'adwords_api'
|
30
|
+
require 'date'
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
def add_experiment()
|
32
|
+
def add_experiment(campaign_id, ad_group_id, criterion_id)
|
34
33
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
35
34
|
# when called without parameters.
|
36
35
|
adwords = AdwordsApi::Api.new
|
@@ -44,10 +43,6 @@ def add_experiment()
|
|
44
43
|
ad_group_criterion_srv =
|
45
44
|
adwords.service(:AdGroupCriterionService, API_VERSION)
|
46
45
|
|
47
|
-
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
48
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
49
|
-
criterion_id = 'INSERT_CRITERION_ID_HERE'.to_i
|
50
|
-
|
51
46
|
# Prepare for adding experiment.
|
52
47
|
operation = {
|
53
48
|
:operator => 'ADD',
|
@@ -55,7 +50,11 @@ def add_experiment()
|
|
55
50
|
:campaign_id => campaign_id,
|
56
51
|
:name => "Interplanetary Experiment #%d" % (Time.new.to_f * 1000).to_i,
|
57
52
|
:query_percentage => 10,
|
58
|
-
:start_date_time => Time.now.strftime('%Y%m%d %H%M%S')
|
53
|
+
:start_date_time => Time.now.strftime('%Y%m%d %H%M%S'),
|
54
|
+
# Optional fields:
|
55
|
+
:status => 'ACTIVE',
|
56
|
+
:end_date_time =>
|
57
|
+
DateTime.parse((Date.today + 30).to_s).strftime('%Y%m%d %H%M%S')
|
59
58
|
}
|
60
59
|
}
|
61
60
|
|
@@ -132,8 +131,14 @@ def add_experiment()
|
|
132
131
|
end
|
133
132
|
|
134
133
|
if __FILE__ == $0
|
134
|
+
API_VERSION = :v201109
|
135
|
+
|
135
136
|
begin
|
136
|
-
|
137
|
+
# IDs of the required objects.
|
138
|
+
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
139
|
+
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
140
|
+
criterion_id = 'INSERT_CRITERION_ID_HERE'.to_i
|
141
|
+
add_experiment(campaign_id, ad_group_id, criterion_id)
|
137
142
|
|
138
143
|
# HTTP errors.
|
139
144
|
rescue AdsCommon::Errors::HttpError => e
|
@@ -26,11 +26,6 @@
|
|
26
26
|
|
27
27
|
require 'adwords_api'
|
28
28
|
|
29
|
-
API_VERSION = :v201109
|
30
|
-
RETRY_INTERVAL = 30
|
31
|
-
RETRIES_COUNT = 30
|
32
|
-
KEYWORD_NUMBER = 100
|
33
|
-
|
34
29
|
def add_keywords_in_bulk()
|
35
30
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
36
31
|
# when called without parameters.
|
@@ -129,6 +124,11 @@ def add_keywords_in_bulk()
|
|
129
124
|
end
|
130
125
|
|
131
126
|
if __FILE__ == $0
|
127
|
+
API_VERSION = :v201109
|
128
|
+
RETRY_INTERVAL = 30
|
129
|
+
RETRIES_COUNT = 30
|
130
|
+
KEYWORD_NUMBER = 100
|
131
|
+
|
132
132
|
begin
|
133
133
|
add_keywords_in_bulk()
|
134
134
|
|
@@ -25,9 +25,7 @@
|
|
25
25
|
|
26
26
|
require 'adwords_api'
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
def add_location_extension()
|
28
|
+
def add_location_extension(campaign_id)
|
31
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
32
30
|
# when called without parameters.
|
33
31
|
adwords = AdwordsApi::Api.new
|
@@ -40,8 +38,6 @@ def add_location_extension()
|
|
40
38
|
adwords.service(:CampaignAdExtensionService, API_VERSION)
|
41
39
|
geo_location_srv = adwords.service(:GeoLocationService, API_VERSION)
|
42
40
|
|
43
|
-
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
44
|
-
|
45
41
|
selector = {
|
46
42
|
:addresses => [
|
47
43
|
{
|
@@ -78,7 +74,13 @@ def add_location_extension()
|
|
78
74
|
:address => location[:address],
|
79
75
|
:geo_point => location[:geo_point],
|
80
76
|
:encoded_location => location[:encoded_location],
|
81
|
-
:source => 'ADWORDS_FRONTEND'
|
77
|
+
:source => 'ADWORDS_FRONTEND',
|
78
|
+
# Optional fields:
|
79
|
+
#:company_name => 'ACME Inc.',
|
80
|
+
#:phone_number => '+1-650-253-0000'
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
82
84
|
end
|
83
85
|
|
84
86
|
# Add location ad extensions.
|
@@ -90,8 +92,12 @@ def add_location_extension()
|
|
90
92
|
end
|
91
93
|
|
92
94
|
if __FILE__ == $0
|
95
|
+
API_VERSION = :v201109
|
96
|
+
|
93
97
|
begin
|
94
|
-
|
98
|
+
# ID of campaign to add location extension to.
|
99
|
+
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
100
|
+
add_location_extension(campaign_id)
|
95
101
|
|
96
102
|
# HTTP errors.
|
97
103
|
rescue AdsCommon::Errors::HttpError => e
|
@@ -26,9 +26,7 @@
|
|
26
26
|
|
27
27
|
require 'adwords_api'
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
def add_location_extension_override()
|
29
|
+
def add_location_extension_override(ad_id, location_extension_id)
|
32
30
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
33
31
|
# when called without parameters.
|
34
32
|
adwords = AdwordsApi::Api.new
|
@@ -40,9 +38,6 @@ def add_location_extension_override()
|
|
40
38
|
ad_ext_override_srv =
|
41
39
|
adwords.service(:AdExtensionOverrideService, API_VERSION)
|
42
40
|
|
43
|
-
ad_id = 'INSERT_AD_ID_HERE'.to_i
|
44
|
-
location_extension_id = 'INSERT_LOCATION_EXTENSION_ID_HERE'.to_i
|
45
|
-
|
46
41
|
# Create operation.
|
47
42
|
operation = {
|
48
43
|
:operator => 'ADD',
|
@@ -62,8 +57,13 @@ def add_location_extension_override()
|
|
62
57
|
end
|
63
58
|
|
64
59
|
if __FILE__ == $0
|
60
|
+
API_VERSION = :v201109
|
61
|
+
|
65
62
|
begin
|
66
|
-
|
63
|
+
# IDs of ad and location extension override to add.
|
64
|
+
ad_id = 'INSERT_AD_ID_HERE'.to_i
|
65
|
+
location_extension_id = 'INSERT_LOCATION_EXTENSION_ID_HERE'.to_i
|
66
|
+
add_location_extension_override(ad_id, location_extension_id)
|
67
67
|
|
68
68
|
# HTTP errors.
|
69
69
|
rescue AdsCommon::Errors::HttpError => e
|
@@ -25,9 +25,7 @@
|
|
25
25
|
|
26
26
|
require 'adwords_api'
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
def get_all_disapproved_ads()
|
28
|
+
def get_all_disapproved_ads(ad_group_id)
|
31
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
32
30
|
# when called without parameters.
|
33
31
|
adwords = AdwordsApi::Api.new
|
@@ -38,8 +36,6 @@ def get_all_disapproved_ads()
|
|
38
36
|
|
39
37
|
ad_group_ad_srv = adwords.service(:AdGroupAdService, API_VERSION)
|
40
38
|
|
41
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
42
|
-
|
43
39
|
# Get all the disapproved ads for this campaign.
|
44
40
|
selector = {
|
45
41
|
:fields => ['Id', 'DisapprovalReasons'],
|
@@ -72,8 +68,12 @@ def get_all_disapproved_ads()
|
|
72
68
|
end
|
73
69
|
|
74
70
|
if __FILE__ == $0
|
71
|
+
API_VERSION = :v201109
|
72
|
+
|
75
73
|
begin
|
76
|
-
|
74
|
+
# ID of an ad group to get disapproved ads for.
|
75
|
+
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
76
|
+
get_all_disapproved_ads(ad_group_id)
|
77
77
|
|
78
78
|
# HTTP errors.
|
79
79
|
rescue AdsCommon::Errors::HttpError => e
|
@@ -25,9 +25,7 @@
|
|
25
25
|
|
26
26
|
require 'adwords_api'
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
def promote_experiment()
|
28
|
+
def promote_experiment(experiment_id)
|
31
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
32
30
|
# when called without parameters.
|
33
31
|
adwords = AdwordsApi::Api.new
|
@@ -38,8 +36,6 @@ def promote_experiment()
|
|
38
36
|
|
39
37
|
experiment_srv = adwords.service(:ExperimentService, API_VERSION)
|
40
38
|
|
41
|
-
experiment_id = 'INSERT_EXPERIMENT_ID_HERE'.to_i
|
42
|
-
|
43
39
|
# Prepare for updating experiment.
|
44
40
|
operation = {
|
45
41
|
:operator => 'SET',
|
@@ -57,8 +53,11 @@ def promote_experiment()
|
|
57
53
|
end
|
58
54
|
|
59
55
|
if __FILE__ == $0
|
56
|
+
API_VERSION = :v201109
|
57
|
+
|
60
58
|
begin
|
61
|
-
|
59
|
+
experiment_id = 'INSERT_EXPERIMENT_ID_HERE'.to_i
|
60
|
+
promote_experiment(experiment_id)
|
62
61
|
|
63
62
|
# HTTP errors.
|
64
63
|
rescue AdsCommon::Errors::HttpError => e
|
@@ -25,9 +25,7 @@
|
|
25
25
|
|
26
26
|
require 'adwords_api'
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
def set_ad_parameters()
|
28
|
+
def set_ad_parameters(ad_group_id, criterion_id)
|
31
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
32
30
|
# when called without parameters.
|
33
31
|
adwords = AdwordsApi::Api.new
|
@@ -39,9 +37,6 @@ def set_ad_parameters()
|
|
39
37
|
ad_group_ad_srv = adwords.service(:AdGroupAdService, API_VERSION)
|
40
38
|
ad_param_srv = adwords.service(:AdParamService, API_VERSION)
|
41
39
|
|
42
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
43
|
-
criterion_id = 'INSERT_CRITERION_ID_HERE'.to_i
|
44
|
-
|
45
40
|
# Prepare for adding ad.
|
46
41
|
ad_operation = {
|
47
42
|
:operator => 'ADD',
|
@@ -64,7 +59,7 @@ def set_ad_parameters()
|
|
64
59
|
# Add ad.
|
65
60
|
response = ad_group_ad_srv.mutate([ad_operation])
|
66
61
|
ad = response[:value].first[:ad]
|
67
|
-
puts
|
62
|
+
puts "Text ad ID %d was successfully added." % ad[:id]
|
68
63
|
|
69
64
|
# Prepare for setting ad parameters.
|
70
65
|
price_operation = {
|
@@ -93,8 +88,13 @@ def set_ad_parameters()
|
|
93
88
|
end
|
94
89
|
|
95
90
|
if __FILE__ == $0
|
91
|
+
API_VERSION = :v201109
|
92
|
+
|
96
93
|
begin
|
97
|
-
|
94
|
+
# IDs of ad group and criterion to set ad parameter for.
|
95
|
+
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
96
|
+
criterion_id = 'INSERT_CRITERION_ID_HERE'.to_i
|
97
|
+
set_ad_parameters(ad_group_id, criterion_id)
|
98
98
|
|
99
99
|
# HTTP errors.
|
100
100
|
rescue AdsCommon::Errors::HttpError => e
|
@@ -25,9 +25,7 @@
|
|
25
25
|
|
26
26
|
require 'adwords_api'
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
def validate_text_ad()
|
28
|
+
def validate_text_ad(ad_group_id)
|
31
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
32
30
|
# when called without parameters.
|
33
31
|
adwords = AdwordsApi::Api.new
|
@@ -38,8 +36,6 @@ def validate_text_ad()
|
|
38
36
|
|
39
37
|
ad_group_ad_srv = adwords.service(:AdGroupAdService, API_VERSION)
|
40
38
|
|
41
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
42
|
-
|
43
39
|
# Enable 'validate only' option.
|
44
40
|
adwords.validate_only = true
|
45
41
|
|
@@ -77,18 +73,20 @@ def validate_text_ad()
|
|
77
73
|
response = ad_group_ad_srv.mutate([operation])
|
78
74
|
if response and response[:value]
|
79
75
|
ad = response[:value].first
|
80
|
-
|
81
|
-
[campaign[:name], campaign[:id], campaign[:status]]
|
76
|
+
raise StandardError, ("Unexpected ad creation! Name '%s', ID %d and " +
|
77
|
+
"status '%s'.") % [campaign[:name], campaign[:id], campaign[:status]]
|
82
78
|
end
|
83
79
|
rescue AdwordsApi::Errors::ApiException => e
|
84
80
|
puts "Validation correctly failed with an exception: %s" % e.class
|
85
|
-
raise e
|
86
81
|
end
|
87
82
|
end
|
88
83
|
|
89
84
|
if __FILE__ == $0
|
85
|
+
API_VERSION = :v201109
|
86
|
+
|
90
87
|
begin
|
91
|
-
|
88
|
+
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
89
|
+
validate_text_ad(ad_group_id)
|
92
90
|
|
93
91
|
# HTTP errors.
|
94
92
|
rescue AdsCommon::Errors::HttpError => e
|
@@ -25,10 +25,6 @@
|
|
25
25
|
|
26
26
|
require 'adwords_api'
|
27
27
|
|
28
|
-
API_VERSION = :v201109
|
29
|
-
|
30
|
-
MAX_RETRIES = 500
|
31
|
-
|
32
28
|
def handle_captcha_challenge()
|
33
29
|
# Initialize token variable.
|
34
30
|
logintoken = nil
|
@@ -73,6 +69,9 @@ def handle_captcha_challenge()
|
|
73
69
|
end
|
74
70
|
|
75
71
|
if __FILE__ == $0
|
72
|
+
API_VERSION = :v201109
|
73
|
+
MAX_RETRIES = 500
|
74
|
+
|
76
75
|
begin
|
77
76
|
handle_captcha_challenge()
|
78
77
|
|
@@ -25,9 +25,7 @@
|
|
25
25
|
require 'adwords_api'
|
26
26
|
require 'adwords_api/utils'
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
def handle_partial_failures()
|
28
|
+
def handle_partial_failures(ad_group_id)
|
31
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
32
30
|
# when called without parameters.
|
33
31
|
adwords = AdwordsApi::Api.new
|
@@ -39,8 +37,6 @@ def handle_partial_failures()
|
|
39
37
|
ad_group_criterion_srv =
|
40
38
|
adwords.service(:AdGroupCriterionService, API_VERSION)
|
41
39
|
|
42
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
43
|
-
|
44
40
|
# Set partial failures flag.
|
45
41
|
adwords.partial_failure = true
|
46
42
|
|
@@ -106,8 +102,11 @@ def handle_partial_failures()
|
|
106
102
|
end
|
107
103
|
|
108
104
|
if __FILE__ == $0
|
105
|
+
API_VERSION = :v201109
|
106
|
+
|
109
107
|
begin
|
110
|
-
|
108
|
+
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
109
|
+
handle_partial_failures(ad_group_id)
|
111
110
|
|
112
111
|
# HTTP errors.
|
113
112
|
rescue AdsCommon::Errors::HttpError => e
|
@@ -26,9 +26,7 @@
|
|
26
26
|
require 'adwords_api'
|
27
27
|
require 'adwords_api/utils'
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
def handle_policy_violation_error()
|
29
|
+
def handle_policy_violation_error(ad_group_id)
|
32
30
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
33
31
|
# when called without parameters.
|
34
32
|
adwords = AdwordsApi::Api.new
|
@@ -39,8 +37,6 @@ def handle_policy_violation_error()
|
|
39
37
|
|
40
38
|
ad_group_ad_srv = adwords.service(:AdGroupAdService, API_VERSION)
|
41
39
|
|
42
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
43
|
-
|
44
40
|
# Create text ad.
|
45
41
|
text_ad_operation = {
|
46
42
|
:operator => 'ADD',
|
@@ -117,8 +113,11 @@ def handle_policy_violation_error()
|
|
117
113
|
end
|
118
114
|
|
119
115
|
if __FILE__ == $0
|
116
|
+
API_VERSION = :v201109
|
117
|
+
|
120
118
|
begin
|
121
|
-
|
119
|
+
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
120
|
+
handle_policy_violation_error(ad_group_id)
|
122
121
|
|
123
122
|
# HTTP errors.
|
124
123
|
rescue AdsCommon::Errors::HttpError => e
|
@@ -22,8 +22,6 @@
|
|
22
22
|
|
23
23
|
require 'adwords_api'
|
24
24
|
|
25
|
-
API_VERSION = :v201109
|
26
|
-
|
27
25
|
def handle_two_factor_authorization_error()
|
28
26
|
# Set up credentials with an account that has 2Factor enabled.
|
29
27
|
config = {
|
@@ -66,6 +64,8 @@ def handle_two_factor_authorization_error()
|
|
66
64
|
end
|
67
65
|
|
68
66
|
if __FILE__ == $0
|
67
|
+
API_VERSION = :v201109
|
68
|
+
|
69
69
|
begin
|
70
70
|
handle_two_factor_authorization_error()
|
71
71
|
|