google-adx-buyer-api 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5 -1
- data/README +12 -9
- data/examples/v201206/campaign_management/add_placements_in_bulk.rb +1 -1
- data/examples/v201209/campaign_management/add_placements_in_bulk.rb +1 -1
- data/examples/v201209/error_handling/handle_two_factor_authorization_error.rb +2 -1
- data/examples/v201209/misc/get_all_images_and_videos.rb +3 -4
- data/examples/v201209/misc/upload_image.rb +11 -9
- data/examples/{v201109_1/misc/use_oauth.rb → v201209/misc/use_oauth2.rb} +24 -24
- data/examples/v201209/misc/{use_oauth.rb → use_oauth2_jwt.rb} +19 -23
- data/examples/v201209/optimization/get_placement_ideas.rb +1 -3
- data/examples/v201209/remarketing/add_audience.rb +27 -23
- data/examples/v201209/remarketing/add_conversion_tracker.rb +8 -4
- data/examples/v201209/targeting/get_targetable_languages_and_carriers.rb +7 -3
- metadata +34 -132
- data/examples/v201109/account_management/get_account_changes.rb +0 -137
- data/examples/v201109/basic_operations/add_ad_group.rb +0 -88
- data/examples/v201109/basic_operations/add_campaign.rb +0 -98
- data/examples/v201109/basic_operations/add_placements.rb +0 -99
- data/examples/v201109/basic_operations/add_thirdparty_redirect_ad.rb +0 -105
- data/examples/v201109/basic_operations/delete_ad.rb +0 -80
- data/examples/v201109/basic_operations/delete_ad_group.rb +0 -76
- data/examples/v201109/basic_operations/delete_campaign.rb +0 -77
- data/examples/v201109/basic_operations/delete_placement.rb +0 -86
- data/examples/v201109/basic_operations/get_ad_groups.rb +0 -80
- data/examples/v201109/basic_operations/get_campaigns.rb +0 -77
- data/examples/v201109/basic_operations/get_placements.rb +0 -92
- data/examples/v201109/basic_operations/get_thirdparty_redirect_ads.rb +0 -100
- data/examples/v201109/basic_operations/pause_ad.rb +0 -81
- data/examples/v201109/basic_operations/update_ad_group.rb +0 -76
- data/examples/v201109/basic_operations/update_campaign.rb +0 -79
- data/examples/v201109/basic_operations/update_placement.rb +0 -94
- data/examples/v201109/campaign_management/add_placements_in_bulk.rb +0 -151
- data/examples/v201109/campaign_management/get_all_disapproved_ads.rb +0 -92
- data/examples/v201109/error_handling/handle_captcha_challenge.rb +0 -93
- data/examples/v201109/error_handling/handle_partial_failures.rb +0 -117
- data/examples/v201109/error_handling/handle_policy_violation_error.rb +0 -138
- data/examples/v201109/error_handling/handle_two_factor_authorization_error.rb +0 -87
- data/examples/v201109/misc/get_all_images_and_videos.rb +0 -101
- data/examples/v201109/misc/upload_image.rb +0 -87
- data/examples/v201109/misc/use_oauth.rb +0 -97
- data/examples/v201109/optimization/get_placement_ideas.rb +0 -106
- data/examples/v201109/remarketing/add_audience.rb +0 -111
- data/examples/v201109/remarketing/add_conversion_tracker.rb +0 -93
- data/examples/v201109/reporting/download_criteria_report.rb +0 -79
- data/examples/v201109/reporting/download_defined_report.rb +0 -67
- data/examples/v201109/reporting/get_campaign_stats.rb +0 -105
- data/examples/v201109/reporting/get_defined_reports.rb +0 -75
- data/examples/v201109/reporting/get_report_fields.rb +0 -71
- data/examples/v201109/reporting/parallel_report_download.rb +0 -159
- data/examples/v201109/targeting/add_campaign_targeting_criteria.rb +0 -110
- data/examples/v201109/targeting/get_campaign_targeting_criteria.rb +0 -104
- data/examples/v201109/targeting/get_targetable_languages_and_carriers.rb +0 -82
- data/examples/v201109/targeting/lookup_location.rb +0 -103
- data/examples/v201109_1/account_management/get_account_changes.rb +0 -137
- data/examples/v201109_1/basic_operations/add_ad_group.rb +0 -88
- data/examples/v201109_1/basic_operations/add_campaign.rb +0 -98
- data/examples/v201109_1/basic_operations/add_placements.rb +0 -99
- data/examples/v201109_1/basic_operations/add_thirdparty_redirect_ad.rb +0 -105
- data/examples/v201109_1/basic_operations/delete_ad.rb +0 -80
- data/examples/v201109_1/basic_operations/delete_ad_group.rb +0 -76
- data/examples/v201109_1/basic_operations/delete_campaign.rb +0 -77
- data/examples/v201109_1/basic_operations/delete_placement.rb +0 -86
- data/examples/v201109_1/basic_operations/get_ad_groups.rb +0 -80
- data/examples/v201109_1/basic_operations/get_campaigns.rb +0 -77
- data/examples/v201109_1/basic_operations/get_placements.rb +0 -92
- data/examples/v201109_1/basic_operations/get_thirdparty_redirect_ads.rb +0 -100
- data/examples/v201109_1/basic_operations/pause_ad.rb +0 -81
- data/examples/v201109_1/basic_operations/update_ad_group.rb +0 -76
- data/examples/v201109_1/basic_operations/update_campaign.rb +0 -79
- data/examples/v201109_1/basic_operations/update_placement.rb +0 -94
- data/examples/v201109_1/campaign_management/add_placements_in_bulk.rb +0 -151
- data/examples/v201109_1/campaign_management/get_all_disapproved_ads.rb +0 -92
- data/examples/v201109_1/error_handling/handle_captcha_challenge.rb +0 -93
- data/examples/v201109_1/error_handling/handle_partial_failures.rb +0 -117
- data/examples/v201109_1/error_handling/handle_policy_violation_error.rb +0 -138
- data/examples/v201109_1/error_handling/handle_two_factor_authorization_error.rb +0 -87
- data/examples/v201109_1/misc/get_all_images_and_videos.rb +0 -101
- data/examples/v201109_1/misc/upload_image.rb +0 -87
- data/examples/v201109_1/optimization/get_placement_ideas.rb +0 -106
- data/examples/v201109_1/remarketing/add_audience.rb +0 -111
- data/examples/v201109_1/remarketing/add_conversion_tracker.rb +0 -93
- data/examples/v201109_1/reporting/download_criteria_report.rb +0 -79
- data/examples/v201109_1/reporting/download_defined_report.rb +0 -67
- data/examples/v201109_1/reporting/get_campaign_stats.rb +0 -105
- data/examples/v201109_1/reporting/get_defined_reports.rb +0 -75
- data/examples/v201109_1/reporting/get_report_fields.rb +0 -71
- data/examples/v201109_1/reporting/parallel_report_download.rb +0 -159
- data/examples/v201109_1/targeting/add_campaign_targeting_criteria.rb +0 -110
- data/examples/v201109_1/targeting/get_campaign_targeting_criteria.rb +0 -104
- data/examples/v201109_1/targeting/get_targetable_languages_and_carriers.rb +0 -82
- data/examples/v201109_1/targeting/lookup_location.rb +0 -103
- data/examples/v201209/reporting/parallel_report_download.rb +0 -159
@@ -1,98 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example illustrates how to create a campaign.
|
22
|
-
#
|
23
|
-
# Tags: CampaignService.mutate
|
24
|
-
|
25
|
-
require 'adwords_api'
|
26
|
-
|
27
|
-
def add_campaign()
|
28
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
29
|
-
# when called without parameters.
|
30
|
-
adwords = AdwordsApi::Api.new
|
31
|
-
|
32
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
33
|
-
# the configuration file or provide your own logger:
|
34
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
35
|
-
|
36
|
-
campaign_srv = adwords.service(:CampaignService, API_VERSION)
|
37
|
-
|
38
|
-
# Prepare for adding campaign.
|
39
|
-
operation = {
|
40
|
-
:operator => 'ADD',
|
41
|
-
:operand => {
|
42
|
-
:name => 'Interplanetary Cruise #%s' % (Time.new.to_f * 1000).to_i,
|
43
|
-
:status => 'PAUSED',
|
44
|
-
:bidding_strategy => {
|
45
|
-
# The 'xsi_type' field allows you to specify the xsi:type of the object
|
46
|
-
# being created. It's only necessary when you must provide an explicit
|
47
|
-
# type that the client library can't infer.
|
48
|
-
:xsi_type => 'ManualCPM'
|
49
|
-
},
|
50
|
-
:budget => {
|
51
|
-
:period => 'DAILY',
|
52
|
-
:amount => {
|
53
|
-
:micro_amount => 50000000
|
54
|
-
},
|
55
|
-
:delivery_method => 'STANDARD'
|
56
|
-
},
|
57
|
-
# Set the campaign network options to Search and Search Network.
|
58
|
-
:network_setting => {
|
59
|
-
:target_google_search => false,
|
60
|
-
:target_search_network => false,
|
61
|
-
:target_content_network => true,
|
62
|
-
:target_content_contextual => false
|
63
|
-
},
|
64
|
-
:settings => [
|
65
|
-
{:xsi_type => 'RealTimeBiddingSetting', :opt_in => 'true'}
|
66
|
-
]
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
# Add campaign.
|
71
|
-
response = campaign_srv.mutate([operation])
|
72
|
-
campaign = response[:value].first
|
73
|
-
puts "Campaign with name '%s' and ID %d was added." %
|
74
|
-
[campaign[:name], campaign[:id]]
|
75
|
-
end
|
76
|
-
|
77
|
-
if __FILE__ == $0
|
78
|
-
API_VERSION = :v201109_1
|
79
|
-
|
80
|
-
begin
|
81
|
-
add_campaign()
|
82
|
-
|
83
|
-
# HTTP errors.
|
84
|
-
rescue AdsCommon::Errors::HttpError => e
|
85
|
-
puts "HTTP Error: %s" % e
|
86
|
-
|
87
|
-
# API errors.
|
88
|
-
rescue AdwordsApi::Errors::ApiException => e
|
89
|
-
puts "Message: %s" % e.message
|
90
|
-
puts 'Errors:'
|
91
|
-
e.errors.each_with_index do |error, index|
|
92
|
-
puts "\tError [%d]:" % (index + 1)
|
93
|
-
error.each do |field, value|
|
94
|
-
puts "\t\t%s: %s" % [field, value]
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example illustrates how to add a placement to a given ad group. To create
|
22
|
-
# an ad group, run add_ad_group.rb.
|
23
|
-
#
|
24
|
-
# Tags: AdGroupCriterionService.mutate
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def add_placements(ad_group_id)
|
29
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
-
# when called without parameters.
|
31
|
-
adwords = AdwordsApi::Api.new
|
32
|
-
|
33
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
-
# the configuration file or provide your own logger:
|
35
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
-
|
37
|
-
ad_group_criterion_srv =
|
38
|
-
adwords.service(:AdGroupCriterionService, API_VERSION)
|
39
|
-
|
40
|
-
# Create placements.
|
41
|
-
placements = [
|
42
|
-
{
|
43
|
-
:xsi_type => 'BiddableAdGroupCriterion',
|
44
|
-
:ad_group_id => ad_group_id,
|
45
|
-
:criterion => {
|
46
|
-
:xsi_type => 'Placement',
|
47
|
-
:url => 'http://mars.google.com'
|
48
|
-
}
|
49
|
-
},
|
50
|
-
{
|
51
|
-
:xsi_type => 'BiddableAdGroupCriterion',
|
52
|
-
:ad_group_id => ad_group_id,
|
53
|
-
:criterion => {
|
54
|
-
:xsi_type => 'Placement',
|
55
|
-
:url => 'http://pluto.google.com'
|
56
|
-
}
|
57
|
-
},
|
58
|
-
]
|
59
|
-
|
60
|
-
# Create operations to add placements.
|
61
|
-
plc_operations = placements.map do |placement|
|
62
|
-
{:operator => 'ADD', :operand => placement}
|
63
|
-
end
|
64
|
-
|
65
|
-
# Add placements.
|
66
|
-
response = ad_group_criterion_srv.mutate(plc_operations)
|
67
|
-
ad_group_criteria = response[:value]
|
68
|
-
puts "Added %d placements to ad group ID %d." %
|
69
|
-
[ad_group_criteria.length, ad_group_id]
|
70
|
-
ad_group_criteria.each do |ad_group_criterion|
|
71
|
-
puts "\tPlacement ID is %d and type is '%s'." %
|
72
|
-
[ad_group_criterion[:criterion][:id],
|
73
|
-
ad_group_criterion[:criterion][:xsi_type]]
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
if __FILE__ == $0
|
78
|
-
API_VERSION = :v201109_1
|
79
|
-
|
80
|
-
begin
|
81
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
82
|
-
add_placements(ad_group_id)
|
83
|
-
|
84
|
-
# HTTP errors.
|
85
|
-
rescue AdsCommon::Errors::HttpError => e
|
86
|
-
puts "HTTP Error: %s" % e
|
87
|
-
|
88
|
-
# API errors.
|
89
|
-
rescue AdwordsApi::Errors::ApiException => e
|
90
|
-
puts "Message: %s" % e.message
|
91
|
-
puts 'Errors:'
|
92
|
-
e.errors.each_with_index do |error, index|
|
93
|
-
puts "\tError [%d]:" % (index + 1)
|
94
|
-
error.each do |field, value|
|
95
|
-
puts "\t\t%s: %s" % [field, value]
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2012, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This code example adds a third party redirect ad to an ad group. To create an
|
22
|
-
# ad group, run add_ad_group.rb.
|
23
|
-
#
|
24
|
-
# Tags: AdGroupAdService.mutate
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def add_thirdparty_redirect_ad(ad_group_id)
|
29
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
-
# when called without parameters.
|
31
|
-
adwords = AdwordsApi::Api.new
|
32
|
-
|
33
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
-
# the configuration file or provide your own logger:
|
35
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
-
|
37
|
-
ad_group_ad_srv = adwords.service(:AdGroupAdService, API_VERSION)
|
38
|
-
|
39
|
-
# Create third party redirect ad.
|
40
|
-
# The 'xsi_type' field allows you to specify the xsi:type of the object
|
41
|
-
# being created. It's only necessary when you must provide an explicit
|
42
|
-
# type that the client library can't infer.
|
43
|
-
redirect_ad = {
|
44
|
-
:xsi_type => 'ThirdPartyRedirectAd',
|
45
|
-
:name => 'Example third party ad %d' % (Time.new.to_f * 1000).to_i,
|
46
|
-
:url => 'http://www.example.com',
|
47
|
-
:dimensions => {
|
48
|
-
:height => 250,
|
49
|
-
:width => 300
|
50
|
-
},
|
51
|
-
# This field normally contains the javascript ad tag.
|
52
|
-
:snippet =>
|
53
|
-
'<img src="https://sandbox.google.com/sandboximages/image.jpg"/>',
|
54
|
-
:impression_beacon_url => 'http://www.examples.com/beacon',
|
55
|
-
:certified_vendor_format_id => 119,
|
56
|
-
:is_cookie_targeted => false,
|
57
|
-
:is_user_interest_targeted => false,
|
58
|
-
:is_tagged => false
|
59
|
-
}
|
60
|
-
|
61
|
-
# Create an operation to add the ad.
|
62
|
-
operation = {
|
63
|
-
:operator => 'ADD',
|
64
|
-
:operand => {
|
65
|
-
:ad_group_id => ad_group_id,
|
66
|
-
:ad => redirect_ad
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
# Add third party redirect ad. Multiple operations could be passed as an
|
71
|
-
# array.
|
72
|
-
response = ad_group_ad_srv.mutate([operation])
|
73
|
-
ads = response[:value]
|
74
|
-
puts "Added %d third party redirect ad(s) to ad group ID %d:" %
|
75
|
-
[ads.length, ad_group_id]
|
76
|
-
ads.each do |ad|
|
77
|
-
puts "\tAd ID %d, type '%s' and status '%s'" %
|
78
|
-
[ad[:ad][:id], ad[:ad][:ad_type], ad[:status]]
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
if __FILE__ == $0
|
83
|
-
API_VERSION = :v201109_1
|
84
|
-
|
85
|
-
begin
|
86
|
-
# Ad group ID to add text ads to.
|
87
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
88
|
-
add_thirdparty_redirect_ad(ad_group_id)
|
89
|
-
|
90
|
-
# HTTP errors.
|
91
|
-
rescue AdsCommon::Errors::HttpError => e
|
92
|
-
puts "HTTP Error: %s" % e
|
93
|
-
|
94
|
-
# API errors.
|
95
|
-
rescue AdwordsApi::Errors::ApiException => e
|
96
|
-
puts "Message: %s" % e.message
|
97
|
-
puts 'Errors:'
|
98
|
-
e.errors.each_with_index do |error, index|
|
99
|
-
puts "\tError [%d]:" % (index + 1)
|
100
|
-
error.each do |field, value|
|
101
|
-
puts "\t\t%s: %s" % [field, value]
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example deletes an ad using the 'REMOVE' operator. To get ads,
|
22
|
-
# run get_thirdparty_redirect_ads.rb.
|
23
|
-
#
|
24
|
-
# Tags: AdGroupAdService.mutate
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def delete_ad(ad_group_id, ad_id)
|
29
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
-
# when called without parameters.
|
31
|
-
adwords = AdwordsApi::Api.new
|
32
|
-
|
33
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
-
# the configuration file or provide your own logger:
|
35
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
-
|
37
|
-
ad_group_ad_srv = adwords.service(:AdGroupAdService, API_VERSION)
|
38
|
-
|
39
|
-
# Prepare for deleting ad.
|
40
|
-
operation = {
|
41
|
-
:operator => 'REMOVE',
|
42
|
-
:operand => {
|
43
|
-
:ad_group_id => ad_group_id,
|
44
|
-
:ad => {
|
45
|
-
:xsi_type => 'Ad',
|
46
|
-
:id => ad_id
|
47
|
-
}
|
48
|
-
}
|
49
|
-
}
|
50
|
-
|
51
|
-
# Delete ad.
|
52
|
-
response = ad_group_ad_srv.mutate([operation])
|
53
|
-
ad = response[:value].first
|
54
|
-
puts "Ad ID %d was successfully deleted." % ad[:ad][:id]
|
55
|
-
end
|
56
|
-
|
57
|
-
if __FILE__ == $0
|
58
|
-
API_VERSION = :v201109_1
|
59
|
-
|
60
|
-
begin
|
61
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
62
|
-
ad_id = 'INSERT_AD_ID_HERE'.to_i
|
63
|
-
delete_ad(ad_group_id, ad_id)
|
64
|
-
|
65
|
-
# HTTP errors.
|
66
|
-
rescue AdsCommon::Errors::HttpError => e
|
67
|
-
puts "HTTP Error: %s" % e
|
68
|
-
|
69
|
-
# API errors.
|
70
|
-
rescue AdwordsApi::Errors::ApiException => e
|
71
|
-
puts "Message: %s" % e.message
|
72
|
-
puts 'Errors:'
|
73
|
-
e.errors.each_with_index do |error, index|
|
74
|
-
puts "\tError [%d]:" % (index + 1)
|
75
|
-
error.each do |field, value|
|
76
|
-
puts "\t\t%s: %s" % [field, value]
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.sgomes@gmail.com (Sérgio Gomes)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example deletes an ad group by setting the status to 'DELETED'.
|
22
|
-
# To get ad groups, run get_ad_groups.rb.
|
23
|
-
#
|
24
|
-
# Tags: AdGroupService.mutate
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def delete_ad_group(ad_group_id)
|
29
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
-
# when called without parameters.
|
31
|
-
adwords = AdwordsApi::Api.new
|
32
|
-
|
33
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
-
# the configuration file or provide your own logger:
|
35
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
-
|
37
|
-
ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
|
38
|
-
|
39
|
-
# Prepare for deleting ad group.
|
40
|
-
operation = {
|
41
|
-
:operator => 'SET',
|
42
|
-
:operand => {
|
43
|
-
:status => 'DELETED',
|
44
|
-
:id => ad_group_id
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
|
-
# Delete ad group.
|
49
|
-
response = ad_group_srv.mutate([operation])
|
50
|
-
ad_group = response[:value].first
|
51
|
-
puts "Ad group ID %d was successfully deleted." % ad_group[:id]
|
52
|
-
end
|
53
|
-
|
54
|
-
if __FILE__ == $0
|
55
|
-
API_VERSION = :v201109_1
|
56
|
-
|
57
|
-
begin
|
58
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
59
|
-
delete_ad_group(ad_group_id)
|
60
|
-
|
61
|
-
# HTTP errors.
|
62
|
-
rescue AdsCommon::Errors::HttpError => e
|
63
|
-
puts "HTTP Error: %s" % e
|
64
|
-
|
65
|
-
# API errors.
|
66
|
-
rescue AdwordsApi::Errors::ApiException => e
|
67
|
-
puts "Message: %s" % e.message
|
68
|
-
puts 'Errors:'
|
69
|
-
e.errors.each_with_index do |error, index|
|
70
|
-
puts "\tError [%d]:" % (index + 1)
|
71
|
-
error.each do |field, value|
|
72
|
-
puts "\t\t%s: %s" % [field, value]
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|