google-adwords-api 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +3 -0
- data/{README → README.md} +0 -0
- data/lib/adwords_api/api_config.rb +0 -76
- data/lib/adwords_api/version.rb +1 -1
- data/test/templates/v201309/basic_operations_get_campaigns.def +1 -1
- data/test/templates/v201309/misc_use_oauth2_jwt.def +1 -1
- metadata +3 -148
- data/examples/v201306/account_management/create_account.rb +0 -95
- data/examples/v201306/account_management/get_account_alerts.rb +0 -122
- data/examples/v201306/account_management/get_account_changes.rb +0 -145
- data/examples/v201306/account_management/get_account_hierarchy.rb +0 -103
- data/examples/v201306/advanced_operations/add_ad_group_bid_modifier.rb +0 -105
- data/examples/v201306/advanced_operations/add_click_to_download_ad.rb +0 -137
- data/examples/v201306/advanced_operations/add_site_links.rb +0 -244
- data/examples/v201306/advanced_operations/create_and_attach_shared_keyword_set.rb +0 -147
- data/examples/v201306/advanced_operations/find_and_remove_criteria_from_shared_set.rb +0 -181
- data/examples/v201306/advanced_operations/get_ad_group_bid_modifiers.rb +0 -106
- data/examples/v201306/basic_operations/add_ad_groups.rb +0 -143
- data/examples/v201306/basic_operations/add_campaigns.rb +0 -162
- data/examples/v201306/basic_operations/add_keywords.rb +0 -116
- data/examples/v201306/basic_operations/add_text_ads.rb +0 -113
- data/examples/v201306/basic_operations/delete_ad.rb +0 -93
- data/examples/v201306/basic_operations/delete_ad_group.rb +0 -110
- data/examples/v201306/basic_operations/delete_campaign.rb +0 -111
- data/examples/v201306/basic_operations/delete_keyword.rb +0 -98
- data/examples/v201306/basic_operations/get_ad_groups.rb +0 -106
- data/examples/v201306/basic_operations/get_campaigns.rb +0 -101
- data/examples/v201306/basic_operations/get_campaigns_with_awql.rb +0 -93
- data/examples/v201306/basic_operations/get_keywords.rb +0 -112
- data/examples/v201306/basic_operations/get_text_ads.rb +0 -114
- data/examples/v201306/basic_operations/pause_ad.rb +0 -92
- data/examples/v201306/basic_operations/update_ad_group.rb +0 -89
- data/examples/v201306/basic_operations/update_campaign.rb +0 -90
- data/examples/v201306/basic_operations/update_keyword.rb +0 -110
- data/examples/v201306/campaign_management/add_experiment.rb +0 -166
- data/examples/v201306/campaign_management/add_keywords_in_bulk.rb +0 -158
- data/examples/v201306/campaign_management/add_location_extension.rb +0 -125
- data/examples/v201306/campaign_management/add_location_extension_override.rb +0 -91
- data/examples/v201306/campaign_management/get_all_disapproved_ads.rb +0 -101
- data/examples/v201306/campaign_management/get_all_disapproved_ads_with_awql.rb +0 -92
- data/examples/v201306/campaign_management/promote_experiment.rb +0 -85
- data/examples/v201306/campaign_management/set_ad_parameters.rb +0 -122
- data/examples/v201306/campaign_management/set_criterion_bid_modifier.rb +0 -110
- data/examples/v201306/campaign_management/validate_text_ad.rb +0 -114
- data/examples/v201306/error_handling/handle_captcha_challenge.rb +0 -93
- data/examples/v201306/error_handling/handle_partial_failures.rb +0 -134
- data/examples/v201306/error_handling/handle_policy_violation_error.rb +0 -145
- data/examples/v201306/error_handling/handle_two_factor_authorization_error.rb +0 -88
- data/examples/v201306/migration/upgrade_legacy_sitelinks.rb +0 -313
- data/examples/v201306/misc/get_all_images_and_videos.rb +0 -108
- data/examples/v201306/misc/setup_oauth2.rb +0 -88
- data/examples/v201306/misc/upload_image.rb +0 -97
- data/examples/v201306/misc/use_oauth2_jwt.rb +0 -97
- data/examples/v201306/optimization/estimate_keyword_traffic.rb +0 -137
- data/examples/v201306/optimization/get_keyword_bid_simulations.rb +0 -100
- data/examples/v201306/optimization/get_keyword_ideas.rb +0 -130
- data/examples/v201306/optimization/get_placement_ideas.rb +0 -112
- data/examples/v201306/remarketing/add_audience.rb +0 -123
- data/examples/v201306/remarketing/add_conversion_tracker.rb +0 -104
- data/examples/v201306/reporting/download_criteria_report.rb +0 -87
- data/examples/v201306/reporting/download_criteria_report_with_awql.rb +0 -86
- data/examples/v201306/reporting/get_campaign_stats.rb +0 -113
- data/examples/v201306/reporting/get_report_fields.rb +0 -79
- data/examples/v201306/reporting/parallel_report_download.rb +0 -171
- data/examples/v201306/targeting/add_campaign_targeting_criteria.rb +0 -123
- data/examples/v201306/targeting/add_demographic_targeting_criteria.rb +0 -116
- data/examples/v201306/targeting/get_campaign_targeting_criteria.rb +0 -110
- data/examples/v201306/targeting/get_targetable_languages_and_carriers.rb +0 -94
- data/examples/v201306/targeting/lookup_location.rb +0 -112
- data/examples/v201402/advanced_operations/add_places_location_extensions.rb~ +0 -159
- data/examples/v201402/basic_operations/add_ad_groups.rb~ +0 -147
- data/examples/v201402/misc/create_ad_words_session_without_properties_file.rb~ +0 -94
- data/examples/v201402/remarketing/add_conversion_tracker.rb~ +0 -109
- data/examples/v201402/shopping_campaigns/add_product_partition_tree.rb~ +0 -269
- data/examples/v201402/shopping_campaigns/add_shopping_campaign.rb~ +0 -136
- data/examples/v201402/shopping_campaigns/get_product_category_taxonomy.rb~ +0 -128
- data/examples/v201402/shopping_campaigns/set_product_sales_channel.rb~ +0 -98
- data/lib/adwords_api/v201306/ad_extension_override_service.rb +0 -38
- data/lib/adwords_api/v201306/ad_extension_override_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/ad_group_ad_service.rb +0 -42
- data/lib/adwords_api/v201306/ad_group_ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/ad_group_bid_modifier_service.rb +0 -38
- data/lib/adwords_api/v201306/ad_group_bid_modifier_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/ad_group_criterion_service.rb +0 -42
- data/lib/adwords_api/v201306/ad_group_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/ad_group_feed_service.rb +0 -38
- data/lib/adwords_api/v201306/ad_group_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/ad_group_service.rb +0 -42
- data/lib/adwords_api/v201306/ad_group_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/ad_param_service.rb +0 -38
- data/lib/adwords_api/v201306/ad_param_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/adwords_user_list_service.rb +0 -38
- data/lib/adwords_api/v201306/adwords_user_list_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/alert_service.rb +0 -34
- data/lib/adwords_api/v201306/alert_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/bidding_strategy_service.rb +0 -38
- data/lib/adwords_api/v201306/bidding_strategy_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/budget_order_service.rb +0 -42
- data/lib/adwords_api/v201306/budget_order_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/budget_service.rb +0 -38
- data/lib/adwords_api/v201306/budget_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/campaign_ad_extension_service.rb +0 -38
- data/lib/adwords_api/v201306/campaign_ad_extension_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/campaign_criterion_service.rb +0 -42
- data/lib/adwords_api/v201306/campaign_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/campaign_feed_service.rb +0 -38
- data/lib/adwords_api/v201306/campaign_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/campaign_service.rb +0 -42
- data/lib/adwords_api/v201306/campaign_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/campaign_shared_set_service.rb +0 -38
- data/lib/adwords_api/v201306/campaign_shared_set_service_registry.rb +0 -47
- data/lib/adwords_api/v201306/constant_data_service.rb +0 -62
- data/lib/adwords_api/v201306/constant_data_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/conversion_tracker_service.rb +0 -38
- data/lib/adwords_api/v201306/conversion_tracker_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/customer_service.rb +0 -34
- data/lib/adwords_api/v201306/customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/customer_sync_service.rb +0 -34
- data/lib/adwords_api/v201306/customer_sync_service_registry.rb +0 -47
- data/lib/adwords_api/v201306/data_service.rb +0 -38
- data/lib/adwords_api/v201306/data_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/experiment_service.rb +0 -38
- data/lib/adwords_api/v201306/experiment_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/feed_item_service.rb +0 -38
- data/lib/adwords_api/v201306/feed_item_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/feed_mapping_service.rb +0 -38
- data/lib/adwords_api/v201306/feed_mapping_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/feed_service.rb +0 -38
- data/lib/adwords_api/v201306/feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/geo_location_service.rb +0 -34
- data/lib/adwords_api/v201306/geo_location_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/location_criterion_service.rb +0 -34
- data/lib/adwords_api/v201306/location_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/managed_customer_service.rb +0 -50
- data/lib/adwords_api/v201306/managed_customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/media_service.rb +0 -38
- data/lib/adwords_api/v201306/media_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/mutate_job_service.rb +0 -42
- data/lib/adwords_api/v201306/mutate_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/report_definition_service.rb +0 -34
- data/lib/adwords_api/v201306/report_definition_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/shared_criterion_service.rb +0 -38
- data/lib/adwords_api/v201306/shared_criterion_service_registry.rb +0 -47
- data/lib/adwords_api/v201306/shared_set_service.rb +0 -38
- data/lib/adwords_api/v201306/shared_set_service_registry.rb +0 -47
- data/lib/adwords_api/v201306/targeting_idea_service.rb +0 -38
- data/lib/adwords_api/v201306/targeting_idea_service_registry.rb +0 -46
- data/lib/adwords_api/v201306/traffic_estimator_service.rb +0 -34
- data/lib/adwords_api/v201306/traffic_estimator_service_registry.rb +0 -46
- data/test/adwords_api/test_adwords_api.rb~ +0 -127
- data/test/templates/v201306/basic_operations_get_campaigns.def +0 -114
- data/test/templates/v201306/misc_use_oauth2_jwt.def +0 -131
|
@@ -1,116 +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 example adds demographic criteria to an ad group. To get ad groups list,
|
|
22
|
-
# run get_ad_groups.rb.
|
|
23
|
-
#
|
|
24
|
-
# Tags: AdGroupCriterionService.mutate
|
|
25
|
-
|
|
26
|
-
require 'adwords_api'
|
|
27
|
-
|
|
28
|
-
def add_demographic_targeting_criteria(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 ad group criteria.
|
|
41
|
-
ad_group_criteria = [
|
|
42
|
-
# Targeting criterion.
|
|
43
|
-
{
|
|
44
|
-
:xsi_type => 'BiddableAdGroupCriterion',
|
|
45
|
-
:ad_group_id => ad_group_id,
|
|
46
|
-
:criterion => {
|
|
47
|
-
:xsi_type => 'Gender',
|
|
48
|
-
# See system codes section for IDs:
|
|
49
|
-
# https://developers.google.com/adwords/api/docs/appendix/genders
|
|
50
|
-
:id => 11
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
# Exclusion criterion.
|
|
54
|
-
{
|
|
55
|
-
:xsi_type => 'NegativeAdGroupCriterion',
|
|
56
|
-
:ad_group_id => ad_group_id,
|
|
57
|
-
:criterion => {
|
|
58
|
-
:xsi_type => 'AgeRange',
|
|
59
|
-
# See system codes section for IDs:
|
|
60
|
-
# https://developers.google.com/adwords/api/docs/appendix/ages
|
|
61
|
-
:id => 503999
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
|
|
66
|
-
# Create operations.
|
|
67
|
-
operations = ad_group_criteria.map do |criterion|
|
|
68
|
-
{:operator => 'ADD', :operand => criterion}
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
response = ad_group_criterion_srv.mutate(operations)
|
|
72
|
-
|
|
73
|
-
if response and response[:value]
|
|
74
|
-
criteria = response[:value]
|
|
75
|
-
criteria.each do |ad_group_criterion|
|
|
76
|
-
criterion = ad_group_criterion[:criterion]
|
|
77
|
-
puts ("Ad group criterion with ad group ID %d, criterion ID %d and " +
|
|
78
|
-
"type '%s' was added.") % [ad_group_criterion[:ad_group_id],
|
|
79
|
-
criterion[:id], criterion[:criterion_type]]
|
|
80
|
-
end
|
|
81
|
-
else
|
|
82
|
-
puts 'No criteria were returned.'
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
if __FILE__ == $0
|
|
87
|
-
API_VERSION = :v201306
|
|
88
|
-
|
|
89
|
-
begin
|
|
90
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'
|
|
91
|
-
add_demographic_targeting_criteria(ad_group_id)
|
|
92
|
-
|
|
93
|
-
# Authorization error.
|
|
94
|
-
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
|
95
|
-
puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
|
|
96
|
-
"OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
|
|
97
|
-
"to retrieve and store OAuth2 tokens."
|
|
98
|
-
puts "See this wiki page for more details:\n\n " +
|
|
99
|
-
'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
|
|
100
|
-
|
|
101
|
-
# HTTP errors.
|
|
102
|
-
rescue AdsCommon::Errors::HttpError => e
|
|
103
|
-
puts "HTTP Error: %s" % e
|
|
104
|
-
|
|
105
|
-
# API errors.
|
|
106
|
-
rescue AdwordsApi::Errors::ApiException => e
|
|
107
|
-
puts "Message: %s" % e.message
|
|
108
|
-
puts 'Errors:'
|
|
109
|
-
e.errors.each_with_index do |error, index|
|
|
110
|
-
puts "\tError [%d]:" % (index + 1)
|
|
111
|
-
error.each do |field, value|
|
|
112
|
-
puts "\t\t%s: %s" % [field, value]
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
@@ -1,110 +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', 'KeywordText'],
|
|
43
|
-
:predicates => [
|
|
44
|
-
{:field => 'CampaignId', :operator => 'EQUALS', :values => [campaign_id]}
|
|
45
|
-
],
|
|
46
|
-
:paging => {
|
|
47
|
-
:start_index => 0,
|
|
48
|
-
:number_results => PAGE_SIZE
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
# Set initial values.
|
|
53
|
-
offset, page = 0, {}
|
|
54
|
-
|
|
55
|
-
begin
|
|
56
|
-
page = campaign_criterion_srv.get(selector)
|
|
57
|
-
if page[:entries]
|
|
58
|
-
page[:entries].each do |typed_criterion|
|
|
59
|
-
negative = typed_criterion[:xsi_type] == 'NegativeCampaignCriterion' ?
|
|
60
|
-
' (negative)' : ''
|
|
61
|
-
criterion = typed_criterion[:criterion]
|
|
62
|
-
puts ("Campaign criterion%s with ID %d, type '%s' and text '%s'" +
|
|
63
|
-
" was found.") %
|
|
64
|
-
[negative, criterion[:id], criterion[:type], criterion[:text]]
|
|
65
|
-
end
|
|
66
|
-
# Increment values to request the next page.
|
|
67
|
-
offset += PAGE_SIZE
|
|
68
|
-
selector[:paging][:start_index] = offset
|
|
69
|
-
end
|
|
70
|
-
end while page[:total_num_entries] > offset
|
|
71
|
-
|
|
72
|
-
if page.include?(:total_num_entries)
|
|
73
|
-
puts "\tCampaign ID %d has %d criteria." %
|
|
74
|
-
[campaign_id, page[:total_num_entries]]
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
if __FILE__ == $0
|
|
79
|
-
API_VERSION = :v201306
|
|
80
|
-
PAGE_SIZE = 500
|
|
81
|
-
|
|
82
|
-
begin
|
|
83
|
-
# Specify campaign ID to get targeting for.
|
|
84
|
-
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
|
85
|
-
get_campaign_targeting_criteria(campaign_id)
|
|
86
|
-
|
|
87
|
-
# Authorization error.
|
|
88
|
-
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
|
89
|
-
puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
|
|
90
|
-
"OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
|
|
91
|
-
"to retrieve and store OAuth2 tokens."
|
|
92
|
-
puts "See this wiki page for more details:\n\n " +
|
|
93
|
-
'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
|
|
94
|
-
|
|
95
|
-
# HTTP errors.
|
|
96
|
-
rescue AdsCommon::Errors::HttpError => e
|
|
97
|
-
puts "HTTP Error: %s" % e
|
|
98
|
-
|
|
99
|
-
# API errors.
|
|
100
|
-
rescue AdwordsApi::Errors::ApiException => e
|
|
101
|
-
puts "Message: %s" % e.message
|
|
102
|
-
puts 'Errors:'
|
|
103
|
-
e.errors.each_with_index do |error, index|
|
|
104
|
-
puts "\tError [%d]:" % (index + 1)
|
|
105
|
-
error.each do |field, value|
|
|
106
|
-
puts "\t\t%s: %s" % [field, value]
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
@@ -1,94 +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
|
-
if carriers
|
|
56
|
-
carriers.each do |carrier|
|
|
57
|
-
puts "Carrier name is '%s', ID is %d and country code is '%s'." %
|
|
58
|
-
[carrier[:name], carrier[:id], carrier[:country_code]]
|
|
59
|
-
end
|
|
60
|
-
else
|
|
61
|
-
puts 'No carriers were retrieved.'
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
if __FILE__ == $0
|
|
66
|
-
API_VERSION = :v201306
|
|
67
|
-
|
|
68
|
-
begin
|
|
69
|
-
get_targetable_languages_and_carriers()
|
|
70
|
-
|
|
71
|
-
# Authorization error.
|
|
72
|
-
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
|
73
|
-
puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
|
|
74
|
-
"OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
|
|
75
|
-
"to retrieve and store OAuth2 tokens."
|
|
76
|
-
puts "See this wiki page for more details:\n\n " +
|
|
77
|
-
'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
|
|
78
|
-
|
|
79
|
-
# HTTP errors.
|
|
80
|
-
rescue AdsCommon::Errors::HttpError => e
|
|
81
|
-
puts "HTTP Error: %s" % e
|
|
82
|
-
|
|
83
|
-
# API errors.
|
|
84
|
-
rescue AdwordsApi::Errors::ApiException => e
|
|
85
|
-
puts "Message: %s" % e.message
|
|
86
|
-
puts 'Errors:'
|
|
87
|
-
e.errors.each_with_index do |error, index|
|
|
88
|
-
puts "\tError [%d]:" % (index + 1)
|
|
89
|
-
error.each do |field, value|
|
|
90
|
-
puts "\t\t%s: %s" % [field, value]
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
@@ -1,112 +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', 'TargetingStatus'],
|
|
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 (%s)") %
|
|
73
|
-
[criterion[:search_term], criterion[:location][:location_name],
|
|
74
|
-
criterion[:location][:criterion_type], criterion[:location][:id],
|
|
75
|
-
parent_location, criterion[:reach],
|
|
76
|
-
criterion[:location][:targeting_status]]
|
|
77
|
-
end
|
|
78
|
-
else
|
|
79
|
-
puts 'No criteria were returned.'
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
if __FILE__ == $0
|
|
84
|
-
API_VERSION = :v201306
|
|
85
|
-
|
|
86
|
-
begin
|
|
87
|
-
lookup_location()
|
|
88
|
-
|
|
89
|
-
# Authorization error.
|
|
90
|
-
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
|
91
|
-
puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
|
|
92
|
-
"OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
|
|
93
|
-
"to retrieve and store OAuth2 tokens."
|
|
94
|
-
puts "See this wiki page for more details:\n\n " +
|
|
95
|
-
'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
|
|
96
|
-
|
|
97
|
-
# HTTP errors.
|
|
98
|
-
rescue AdsCommon::Errors::HttpError => e
|
|
99
|
-
puts "HTTP Error: %s" % e
|
|
100
|
-
|
|
101
|
-
# API errors.
|
|
102
|
-
rescue AdwordsApi::Errors::ApiException => e
|
|
103
|
-
puts "Message: %s" % e.message
|
|
104
|
-
puts 'Errors:'
|
|
105
|
-
e.errors.each_with_index do |error, index|
|
|
106
|
-
puts "\tError [%d]:" % (index + 1)
|
|
107
|
-
error.each do |field, value|
|
|
108
|
-
puts "\t\t%s: %s" % [field, value]
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
end
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# Encoding: utf-8
|
|
3
|
-
#
|
|
4
|
-
# Author:: api.mcloonan@gmail.com (Michael Cloonan)
|
|
5
|
-
#
|
|
6
|
-
# Copyright:: Copyright 2014, 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 adds a feed that syncs feed items from a Google Places account
|
|
22
|
-
# and associates the feed with a customer.
|
|
23
|
-
#
|
|
24
|
-
# Tags: CustomerFeedService.mutate, FeedItemService.mutate
|
|
25
|
-
# Tags: FeedMappingService.mutate, FeedService.mutate
|
|
26
|
-
|
|
27
|
-
require 'adwords_api'
|
|
28
|
-
require 'date'
|
|
29
|
-
|
|
30
|
-
def add_places_location_extensions(places_email_address, places_access_token)
|
|
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
|
-
feed_srv = adwords.service(:FeedService, API_VERSION)
|
|
40
|
-
customer_feed_srv = adwords.service(:CustomerFeedService, API_VERSION)
|
|
41
|
-
|
|
42
|
-
places_feed = {
|
|
43
|
-
:name => "Places feed #%d" % (Time.new.to_f * 1000).to_i,
|
|
44
|
-
:system_feed_generation_data => {
|
|
45
|
-
:xsi_type => 'PlacesLocationFeedData',
|
|
46
|
-
:o_auth_info => {
|
|
47
|
-
:http_method => 'GET',
|
|
48
|
-
:http_request_url => 'https://www.google.com/local/add',
|
|
49
|
-
:http_authorization_header => "Bearer %s" % places_access_token
|
|
50
|
-
},
|
|
51
|
-
:email_address => places_email_address
|
|
52
|
-
},
|
|
53
|
-
# Since this feed's feed items will be managed by AdWords, you must set
|
|
54
|
-
# its origin to ADWORDS.
|
|
55
|
-
:origin => 'ADWORDS'
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
places_operation = {
|
|
59
|
-
:operator => 'ADD',
|
|
60
|
-
:operand => places_feed
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
result = feed_srv.mutate([places_operation])
|
|
64
|
-
added_feed = result[:value].first
|
|
65
|
-
puts "Added places feed with ID %d" % added_feed[:id]
|
|
66
|
-
|
|
67
|
-
# Add a CustomerFeed that associates the feed with this customer for the
|
|
68
|
-
# LOCATION placeholder type.
|
|
69
|
-
customer_feed = {
|
|
70
|
-
:feed_id => added_feed[:id],
|
|
71
|
-
:placeholder_types => PLACEHOLDER_TYPE_LOCATION,
|
|
72
|
-
:matching_function => {
|
|
73
|
-
:operator => 'IDENTITY',
|
|
74
|
-
:lhsOperand => {
|
|
75
|
-
:xsi_type => 'FunctionArgumentOperand',
|
|
76
|
-
:type => 'BOOLEAN',
|
|
77
|
-
:boolean_value => true
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
customer_feed_operation = {
|
|
83
|
-
:xsi_type => 'CustomerFeedOperation',
|
|
84
|
-
:operator => 'ADD',
|
|
85
|
-
:operand => customer_feed
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
added_customer_feed = nil
|
|
89
|
-
number_of_attempts = 0
|
|
90
|
-
while i < MAX_CUSTOMER_FEED_ADD_ATTEMPTS && !added_customer_feed
|
|
91
|
-
number_of_attempts += 1
|
|
92
|
-
begin
|
|
93
|
-
result = customer_feed_srv.mutate([customer_feed_operation])
|
|
94
|
-
added_customer_feed = result[:value].first
|
|
95
|
-
puts "Attempt #%d to add the CustomerFeed was successful" %
|
|
96
|
-
number_of_attempts
|
|
97
|
-
rescue
|
|
98
|
-
sleep_seconds = 5 * (2 ** number_of_attempts)
|
|
99
|
-
puts ("Attempt #%d to add the CustomerFeed was not succeessful. " +
|
|
100
|
-
"Waiting %d seconds before trying again.") %
|
|
101
|
-
[number_of_attempts, sleep_seconds]
|
|
102
|
-
sleep(sleep_seconds)
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
unless added_customer_feed
|
|
107
|
-
raise StandardError, ("Could not create the CustomerFeed after %d " +
|
|
108
|
-
"attempts. Please retry the CustomerFeed ADD operation later.") %
|
|
109
|
-
MAX_CUSTOMER_FEED_ADD_ATTEMPTS
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
puts "Added CustomerFeed for feed ID %d and placeholder type %d" %
|
|
113
|
-
[added_customer_feed[:id], added_customer_feed[:placeholder_types].first]
|
|
114
|
-
|
|
115
|
-
# OPTIONAL: Create a CampaignFeed to specify which FeedItems to use at the
|
|
116
|
-
# Campaign level. This will be similar to the CampaignFeed in the
|
|
117
|
-
# add_site_links example, except you can filter based on the business name
|
|
118
|
-
# and category of each FeedItem by using a FeedAttributeOperand in your
|
|
119
|
-
# matching function.
|
|
120
|
-
|
|
121
|
-
# OPTIONAL: Create an AdGroupFeed for even more fine grained control over
|
|
122
|
-
# which feed items are used at the AdGroup level.
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
if __FILE__ == $0
|
|
126
|
-
API_VERSION = :v201402
|
|
127
|
-
PLACEHOLDER_TYPE_LOCATION = 7
|
|
128
|
-
MAX_CUSTOMER_FEED_ADD_ATTEMPTS = 10
|
|
129
|
-
|
|
130
|
-
begin
|
|
131
|
-
places_email_address = 'INSERT_PLACES_EMAIL_ADDRESS_HERE'
|
|
132
|
-
places_access_token = 'INSERT_PLACES_ACCESS_TOKEN_HERE'
|
|
133
|
-
|
|
134
|
-
add_places_location_extensions(places_email_address, places_access_token)
|
|
135
|
-
|
|
136
|
-
# Authorization error.
|
|
137
|
-
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
|
138
|
-
puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
|
|
139
|
-
"OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
|
|
140
|
-
"to retrieve and store OAuth2 tokens."
|
|
141
|
-
puts "See this wiki page for more details:\n\n " +
|
|
142
|
-
'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
|
|
143
|
-
|
|
144
|
-
# HTTP errors.
|
|
145
|
-
rescue AdsCommon::Errors::HttpError => e
|
|
146
|
-
puts "HTTP Error: %s" % e
|
|
147
|
-
|
|
148
|
-
# API errors.
|
|
149
|
-
rescue AdwordsApi::Errors::ApiException => e
|
|
150
|
-
puts "Message: %s" % e.message
|
|
151
|
-
puts 'Errors:'
|
|
152
|
-
e.errors.each_with_index do |error, index|
|
|
153
|
-
puts "\tError [%d]:" % (index + 1)
|
|
154
|
-
error.each do |field, value|
|
|
155
|
-
puts "\t\t%s: %s" % [field, value]
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
end
|