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,104 +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 retrieve all the campaign targets. To set
|
22
|
-
# campaign targets, run add_campaign_targeting_criteria.rb.
|
23
|
-
#
|
24
|
-
# Tags: CampaignCriterionService.get
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def get_campaign_targeting_criteria(campaign_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
|
-
campaign_criterion_srv =
|
38
|
-
adwords.service(:CampaignCriterionService, API_VERSION)
|
39
|
-
|
40
|
-
# Selector to get all the targeting for this campaign.
|
41
|
-
selector = {
|
42
|
-
:fields => ['Id', 'CriteriaType', 'PlacementUrl'],
|
43
|
-
:predicates => [
|
44
|
-
{:field => 'CampaignId', :operator => 'EQUALS', :values => [campaign_id]},
|
45
|
-
{
|
46
|
-
:field => 'CriteriaType',
|
47
|
-
:operator => 'EQUALS',
|
48
|
-
:values => ['PLACEMENT']
|
49
|
-
}
|
50
|
-
],
|
51
|
-
:paging => {
|
52
|
-
:start_index => 0,
|
53
|
-
:number_results => PAGE_SIZE
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
# Set initial values.
|
58
|
-
offset, page = 0, {}
|
59
|
-
|
60
|
-
begin
|
61
|
-
page = campaign_criterion_srv.get(selector)
|
62
|
-
if page[:entries]
|
63
|
-
page[:entries].each do |criterion|
|
64
|
-
placement = criterion[:criterion]
|
65
|
-
puts "Placement with ID %d, type '%s' and URL '%s' was found." %
|
66
|
-
[placement[:id], placement[:type], placement[:url]]
|
67
|
-
end
|
68
|
-
# Increment values to request the next page.
|
69
|
-
offset += PAGE_SIZE
|
70
|
-
selector[:paging][:start_index] = offset
|
71
|
-
end
|
72
|
-
end while page[:total_num_entries] > offset
|
73
|
-
|
74
|
-
if page.include?(:total_num_entries)
|
75
|
-
puts "\tCampaign ID %d has %d placements." %
|
76
|
-
[campaign_id, page[:total_num_entries]]
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
if __FILE__ == $0
|
81
|
-
API_VERSION = :v201109
|
82
|
-
PAGE_SIZE = 500
|
83
|
-
|
84
|
-
begin
|
85
|
-
# Specify campaign ID to get targeting for.
|
86
|
-
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
87
|
-
get_campaign_targeting_criteria(campaign_id)
|
88
|
-
|
89
|
-
# HTTP errors.
|
90
|
-
rescue AdsCommon::Errors::HttpError => e
|
91
|
-
puts "HTTP Error: %s" % e
|
92
|
-
|
93
|
-
# API errors.
|
94
|
-
rescue AdwordsApi::Errors::ApiException => e
|
95
|
-
puts "Message: %s" % e.message
|
96
|
-
puts 'Errors:'
|
97
|
-
e.errors.each_with_index do |error, index|
|
98
|
-
puts "\tError [%d]:" % (index + 1)
|
99
|
-
error.each do |field, value|
|
100
|
-
puts "\t\t%s: %s" % [field, value]
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,82 +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 retrieve all languages and carriers available
|
22
|
-
# for targeting.
|
23
|
-
#
|
24
|
-
# Tags: ConstantDataService.getLanguageCriterion
|
25
|
-
# Tags: ConstantDataService.getCarrierCriterion
|
26
|
-
|
27
|
-
require 'adwords_api'
|
28
|
-
|
29
|
-
def get_targetable_languages_and_carriers()
|
30
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
31
|
-
# when called without parameters.
|
32
|
-
adwords = AdwordsApi::Api.new
|
33
|
-
|
34
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
35
|
-
# the configuration file or provide your own logger:
|
36
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
37
|
-
|
38
|
-
constant_data_srv = adwords.service(:ConstantDataService, API_VERSION)
|
39
|
-
|
40
|
-
# Get all languages from ConstantDataService.
|
41
|
-
languages = constant_data_srv.get_language_criterion()
|
42
|
-
|
43
|
-
if languages
|
44
|
-
languages.each do |language|
|
45
|
-
puts "Language name is '%s', ID is %d and code is '%s'." %
|
46
|
-
[language[:name], language[:id], language[:code]]
|
47
|
-
end
|
48
|
-
else
|
49
|
-
puts 'No languages were found.'
|
50
|
-
end
|
51
|
-
|
52
|
-
# Get all carriers from ConstantDataService.
|
53
|
-
carriers = constant_data_srv.get_carrier_criterion()
|
54
|
-
|
55
|
-
carriers.each do |carrier|
|
56
|
-
puts "Carrier name is '%s', ID is %d and country code is '%s'." %
|
57
|
-
[carrier[:name], carrier[:id], carrier[:country_code]]
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
if __FILE__ == $0
|
62
|
-
API_VERSION = :v201109
|
63
|
-
|
64
|
-
begin
|
65
|
-
get_targetable_languages_and_carriers()
|
66
|
-
|
67
|
-
# HTTP errors.
|
68
|
-
rescue AdsCommon::Errors::HttpError => e
|
69
|
-
puts "HTTP Error: %s" % e
|
70
|
-
|
71
|
-
# API errors.
|
72
|
-
rescue AdwordsApi::Errors::ApiException => e
|
73
|
-
puts "Message: %s" % e.message
|
74
|
-
puts 'Errors:'
|
75
|
-
e.errors.each_with_index do |error, index|
|
76
|
-
puts "\tError [%d]:" % (index + 1)
|
77
|
-
error.each do |field, value|
|
78
|
-
puts "\t\t%s: %s" % [field, value]
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,103 +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 gets location criteria by name.
|
22
|
-
#
|
23
|
-
# Tags: LocationCriterionService.get
|
24
|
-
|
25
|
-
require 'adwords_api'
|
26
|
-
|
27
|
-
def lookup_location()
|
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
|
-
location_criterion_srv =
|
37
|
-
adwords.service(:LocationCriterionService, API_VERSION)
|
38
|
-
|
39
|
-
# List of locations to look up.
|
40
|
-
location_names = ['Paris', 'Quebec', 'Spain', 'Deutschland']
|
41
|
-
# Locale to retrieve names in.
|
42
|
-
locale = 'en'
|
43
|
-
|
44
|
-
# Get the criteria by names.
|
45
|
-
selector = {
|
46
|
-
:fields => ['Id', 'LocationName', 'CanonicalName', 'DisplayType',
|
47
|
-
'ParentLocations', 'Reach'],
|
48
|
-
:predicates => [
|
49
|
-
# Location names must match exactly, only EQUALS and IN are supported.
|
50
|
-
{:field => 'LocationName',
|
51
|
-
:operator => 'IN',
|
52
|
-
:values => location_names},
|
53
|
-
# Set the locale of the returned location names.
|
54
|
-
{:field => 'Locale', :operator => 'EQUALS', :values => [locale]}
|
55
|
-
]
|
56
|
-
}
|
57
|
-
criteria = location_criterion_srv.get(selector)
|
58
|
-
|
59
|
-
if criteria
|
60
|
-
criteria.each do |criterion|
|
61
|
-
# Extract all parent location names as one comma-separated string.
|
62
|
-
parent_location = if criterion[:location][:parent_locations] and
|
63
|
-
!criterion[:location][:parent_locations].empty?
|
64
|
-
locations_array = criterion[:location][:parent_locations].map do |loc|
|
65
|
-
loc[:location_name]
|
66
|
-
end
|
67
|
-
locations_array.join(', ')
|
68
|
-
else
|
69
|
-
'N/A'
|
70
|
-
end
|
71
|
-
puts ("The search term '%s' returned the location '%s' of type '%s' " +
|
72
|
-
"with ID %d, parent locations '%s' and reach %d") %
|
73
|
-
[criterion[:search_term], criterion[:location][:location_name],
|
74
|
-
criterion[:location][:criterion_type], criterion[:location][:id],
|
75
|
-
parent_location, criterion[:reach]]
|
76
|
-
end
|
77
|
-
else
|
78
|
-
puts 'No criteria were returned.'
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
if __FILE__ == $0
|
83
|
-
API_VERSION = :v201109
|
84
|
-
|
85
|
-
begin
|
86
|
-
lookup_location()
|
87
|
-
|
88
|
-
# HTTP errors.
|
89
|
-
rescue AdsCommon::Errors::HttpError => e
|
90
|
-
puts "HTTP Error: %s" % e
|
91
|
-
|
92
|
-
# API errors.
|
93
|
-
rescue AdwordsApi::Errors::ApiException => e
|
94
|
-
puts "Message: %s" % e.message
|
95
|
-
puts 'Errors:'
|
96
|
-
e.errors.each_with_index do |error, index|
|
97
|
-
puts "\tError [%d]:" % (index + 1)
|
98
|
-
error.each do |field, value|
|
99
|
-
puts "\t\t%s: %s" % [field, value]
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,137 +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 gets all account changes that happened within the last 24 hours,
|
22
|
-
# for all your campaigns.
|
23
|
-
#
|
24
|
-
# Tags: CustomerSyncService.get
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
require 'date'
|
28
|
-
require 'pp'
|
29
|
-
|
30
|
-
def get_account_changes()
|
31
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
32
|
-
# when called without parameters.
|
33
|
-
adwords = AdwordsApi::Api.new
|
34
|
-
|
35
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
36
|
-
# the configuration file or provide your own logger:
|
37
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
38
|
-
|
39
|
-
campaign_srv = adwords.service(:CampaignService, API_VERSION)
|
40
|
-
customer_sync_srv = adwords.service(:CustomerSyncService, API_VERSION)
|
41
|
-
|
42
|
-
today_at_midnight = DateTime.parse(Date.today.to_s)
|
43
|
-
yesterday_at_midnight = DateTime.parse((Date.today - 1).to_s)
|
44
|
-
min_date_time = yesterday_at_midnight.strftime("%Y%m%d %H%M%S")
|
45
|
-
max_date_time = today_at_midnight.strftime("%Y%m%d %H%M%S")
|
46
|
-
|
47
|
-
# Get all the campaigns for this account.
|
48
|
-
selector = {
|
49
|
-
:fields => ['Id']
|
50
|
-
}
|
51
|
-
response = campaign_srv.get(selector)
|
52
|
-
|
53
|
-
campaign_ids = []
|
54
|
-
|
55
|
-
if response and response[:entries]
|
56
|
-
campaign_ids = response[:entries].map { |campaign| campaign[:id] }
|
57
|
-
else
|
58
|
-
raise StandardError, 'No campaigns were found.'
|
59
|
-
end
|
60
|
-
|
61
|
-
# Create a selector for CustomerSyncService.
|
62
|
-
selector = {
|
63
|
-
:campaign_ids => campaign_ids,
|
64
|
-
:date_time_range => {
|
65
|
-
:min => min_date_time,
|
66
|
-
:max => max_date_time
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
# Get all account changes for the campaigns.
|
71
|
-
campaign_changes = customer_sync_srv.get(selector)
|
72
|
-
|
73
|
-
# Display changes.
|
74
|
-
if campaign_changes
|
75
|
-
puts "Most recent change: %s" % campaign_changes[:last_change_timestamp]
|
76
|
-
campaign_changes[:changed_campaigns].each do |campaign|
|
77
|
-
puts "Campaign with ID %d was changed:" % campaign[:campaign_id]
|
78
|
-
puts "\tCampaign change status: '%s'" % campaign[:campaign_change_status]
|
79
|
-
unless ['NEW', 'FIELDS_UNCHANGED'].include?(
|
80
|
-
campaign[:campaign_change_status])
|
81
|
-
puts "\tAdded ad extensions: '%s'" %
|
82
|
-
campaign[:added_ad_extensions].pretty_inspect.chomp
|
83
|
-
puts "\tAdded campaign criteria: '%s'" %
|
84
|
-
campaign[:added_campaign_criteria].pretty_inspect.chomp
|
85
|
-
puts "\tAdded campaign targeting: '%s'" %
|
86
|
-
campaign[:campaign_targeting_changed].pretty_inspect.chomp
|
87
|
-
puts "\tDeleted ad extensions: '%s'" %
|
88
|
-
campaign[:deleted_ad_extensions].pretty_inspect.chomp
|
89
|
-
puts "\tDeleted campaign criteria: '%s'" %
|
90
|
-
campaign[:deleted_campaign_criteria].pretty_inspect.chomp
|
91
|
-
|
92
|
-
if campaign[:changed_ad_groups]
|
93
|
-
campaign[:changed_ad_groups].each do |ad_group|
|
94
|
-
puts "\tAd group with ID %d was changed:" % ad_group[:ad_group_id]
|
95
|
-
puts "\t\tAd group changed status: '%s'" %
|
96
|
-
ad_group[:ad_group_change_status]
|
97
|
-
unless ['NEW', 'FIELDS_UNCHANGED'].include?(
|
98
|
-
ad_group[:ad_group_change_status])
|
99
|
-
puts "\t\tAds changed: '%s'" %
|
100
|
-
ad_group[:changed_ads].pretty_inspect.chomp
|
101
|
-
puts "\t\tCriteria changed: '%s'" %
|
102
|
-
ad_group[:changed_criteria].pretty_inspect.chomp
|
103
|
-
puts "\t\tCriteria deleted: '%s'" %
|
104
|
-
ad_group[:deleted_criteria].pretty_inspect.chomp
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
puts
|
110
|
-
end
|
111
|
-
else
|
112
|
-
puts 'No account changes were found.'
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
if __FILE__ == $0
|
117
|
-
API_VERSION = :v201109_1
|
118
|
-
|
119
|
-
begin
|
120
|
-
get_account_changes()
|
121
|
-
|
122
|
-
# HTTP errors.
|
123
|
-
rescue AdsCommon::Errors::HttpError => e
|
124
|
-
puts "HTTP Error: %s" % e
|
125
|
-
|
126
|
-
# API errors.
|
127
|
-
rescue AdwordsApi::Errors::ApiException => e
|
128
|
-
puts "Message: %s" % e.message
|
129
|
-
puts 'Errors:'
|
130
|
-
e.errors.each_with_index do |error, index|
|
131
|
-
puts "\tError [%d]:" % (index + 1)
|
132
|
-
error.each do |field, value|
|
133
|
-
puts "\t\t%s: %s" % [field, value]
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
@@ -1,88 +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 an ad group. To create a campaign, run
|
22
|
-
# add_campaign.rb.
|
23
|
-
#
|
24
|
-
# Tags: AdGroupService.mutate
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def add_ad_group(campaign_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 adding ad group.
|
40
|
-
operation = {
|
41
|
-
:operator => 'ADD',
|
42
|
-
:operand => {
|
43
|
-
:name => 'Earth to Mars Cruises #%s' % (Time.new.to_f * 1000).to_i,
|
44
|
-
:status => 'ENABLED',
|
45
|
-
:campaign_id => campaign_id,
|
46
|
-
:bids => {
|
47
|
-
# The 'xsi_type' field allows you to specify the xsi:type of the object
|
48
|
-
# being created. It's only necessary when you must provide an explicit
|
49
|
-
# type that the client library can't infer.
|
50
|
-
:xsi_type => 'ManualCPMAdGroupBids',
|
51
|
-
:max_cpc => {
|
52
|
-
:amount => {
|
53
|
-
:micro_amount => 10000000
|
54
|
-
}
|
55
|
-
}
|
56
|
-
},
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
# Add ad group.
|
61
|
-
response = ad_group_srv.mutate([operation])
|
62
|
-
ad_group = response[:value].first
|
63
|
-
puts "Ad group ID %d was successfully added." % ad_group[:id]
|
64
|
-
end
|
65
|
-
|
66
|
-
if __FILE__ == $0
|
67
|
-
API_VERSION = :v201109_1
|
68
|
-
|
69
|
-
begin
|
70
|
-
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
71
|
-
add_ad_group(campaign_id)
|
72
|
-
|
73
|
-
# HTTP errors.
|
74
|
-
rescue AdsCommon::Errors::HttpError => e
|
75
|
-
puts "HTTP Error: %s" % e
|
76
|
-
|
77
|
-
# API errors.
|
78
|
-
rescue AdwordsApi::Errors::ApiException => e
|
79
|
-
puts "Message: %s" % e.message
|
80
|
-
puts 'Errors:'
|
81
|
-
e.errors.each_with_index do |error, index|
|
82
|
-
puts "\tError [%d]:" % (index + 1)
|
83
|
-
error.each do |field, value|
|
84
|
-
puts "\t\t%s: %s" % [field, value]
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|