google-adwords-api 0.10.0 → 0.11.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/examples/v201306/misc/setup_oauth2.rb +4 -4
- data/examples/v201306/optimization/get_keyword_ideas.rb +1 -1
- data/examples/v201309/advanced_operations/add_site_links.rb +71 -9
- data/examples/v201309/advanced_operations/update_site_links.rb +194 -0
- data/examples/v201309/misc/setup_oauth2.rb +4 -4
- data/examples/v201309/optimization/get_keyword_ideas.rb +1 -1
- data/lib/adwords_api/api_config.rb +0 -88
- data/lib/adwords_api/version.rb +1 -1
- data/test/templates/v201306/basic_operations_get_campaigns.def +1 -1
- data/test/templates/v201306/misc_use_oauth2_jwt.def +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 +266 -429
- data/examples/v201302/account_management/create_account.rb +0 -95
- data/examples/v201302/account_management/get_account_alerts.rb +0 -122
- data/examples/v201302/account_management/get_account_changes.rb +0 -145
- data/examples/v201302/account_management/get_account_hierarchy.rb +0 -103
- data/examples/v201302/advanced_operations/add_ad_group_bid_modifier.rb +0 -105
- data/examples/v201302/advanced_operations/add_click_to_download_ad.rb +0 -137
- data/examples/v201302/advanced_operations/add_site_links.rb +0 -221
- data/examples/v201302/advanced_operations/create_and_attach_shared_keyword_set.rb +0 -147
- data/examples/v201302/advanced_operations/find_and_remove_criteria_from_shared_set.rb +0 -181
- data/examples/v201302/advanced_operations/get_ad_group_bid_modifiers.rb +0 -106
- data/examples/v201302/adwords_for_video/add_video_call_to_action.rb +0 -94
- data/examples/v201302/adwords_for_video/add_video_campaign.rb +0 -103
- data/examples/v201302/adwords_for_video/find_videos.rb +0 -92
- data/examples/v201302/adwords_for_video/get_keyword_criteria.rb +0 -101
- data/examples/v201302/adwords_for_video/get_targeting_groups.rb +0 -93
- data/examples/v201302/adwords_for_video/get_video_campaign_criteria.rb +0 -99
- data/examples/v201302/adwords_for_video/get_video_campaign_stats.rb +0 -126
- data/examples/v201302/adwords_for_video/get_video_campaigns.rb +0 -94
- data/examples/v201302/basic_operations/add_ad_groups.rb +0 -143
- data/examples/v201302/basic_operations/add_campaigns.rb +0 -162
- data/examples/v201302/basic_operations/add_keywords.rb +0 -116
- data/examples/v201302/basic_operations/add_text_ads.rb +0 -113
- data/examples/v201302/basic_operations/delete_ad.rb +0 -93
- data/examples/v201302/basic_operations/delete_ad_group.rb +0 -110
- data/examples/v201302/basic_operations/delete_campaign.rb +0 -111
- data/examples/v201302/basic_operations/delete_keyword.rb +0 -98
- data/examples/v201302/basic_operations/get_ad_groups.rb +0 -106
- data/examples/v201302/basic_operations/get_campaigns.rb +0 -101
- data/examples/v201302/basic_operations/get_campaigns_with_awql.rb +0 -93
- data/examples/v201302/basic_operations/get_keywords.rb +0 -112
- data/examples/v201302/basic_operations/get_text_ads.rb +0 -114
- data/examples/v201302/basic_operations/pause_ad.rb +0 -92
- data/examples/v201302/basic_operations/update_ad_group.rb +0 -89
- data/examples/v201302/basic_operations/update_campaign.rb +0 -90
- data/examples/v201302/basic_operations/update_keyword.rb +0 -110
- data/examples/v201302/campaign_management/add_experiment.rb +0 -166
- data/examples/v201302/campaign_management/add_keywords_in_bulk.rb +0 -158
- data/examples/v201302/campaign_management/add_location_extension.rb +0 -125
- data/examples/v201302/campaign_management/add_location_extension_override.rb +0 -91
- data/examples/v201302/campaign_management/get_all_disapproved_ads.rb +0 -101
- data/examples/v201302/campaign_management/get_all_disapproved_ads_with_awql.rb +0 -92
- data/examples/v201302/campaign_management/promote_experiment.rb +0 -85
- data/examples/v201302/campaign_management/set_ad_parameters.rb +0 -122
- data/examples/v201302/campaign_management/set_criterion_bid_modifier.rb +0 -110
- data/examples/v201302/campaign_management/validate_text_ad.rb +0 -114
- data/examples/v201302/error_handling/handle_captcha_challenge.rb +0 -93
- data/examples/v201302/error_handling/handle_partial_failures.rb +0 -134
- data/examples/v201302/error_handling/handle_policy_violation_error.rb +0 -145
- data/examples/v201302/error_handling/handle_two_factor_authorization_error.rb +0 -88
- data/examples/v201302/migration/set_campaign_enhanced.rb +0 -91
- data/examples/v201302/migration/upgrade_legacy_sitelinks.rb +0 -313
- data/examples/v201302/misc/get_all_images_and_videos.rb +0 -108
- data/examples/v201302/misc/setup_oauth2.rb +0 -88
- data/examples/v201302/misc/upload_image.rb +0 -97
- data/examples/v201302/misc/use_oauth2_jwt.rb +0 -93
- data/examples/v201302/optimization/estimate_keyword_traffic.rb +0 -137
- data/examples/v201302/optimization/get_keyword_bid_simulations.rb +0 -100
- data/examples/v201302/optimization/get_keyword_ideas.rb +0 -130
- data/examples/v201302/optimization/get_placement_ideas.rb +0 -112
- data/examples/v201302/remarketing/add_audience.rb +0 -123
- data/examples/v201302/remarketing/add_conversion_tracker.rb +0 -104
- data/examples/v201302/reporting/download_criteria_report.rb +0 -87
- data/examples/v201302/reporting/download_criteria_report_with_awql.rb +0 -86
- data/examples/v201302/reporting/get_campaign_stats.rb +0 -113
- data/examples/v201302/reporting/get_report_fields.rb +0 -79
- data/examples/v201302/reporting/parallel_report_download.rb +0 -171
- data/examples/v201302/targeting/add_campaign_targeting_criteria.rb +0 -123
- data/examples/v201302/targeting/add_demographic_targeting_criteria.rb +0 -116
- data/examples/v201302/targeting/get_campaign_targeting_criteria.rb +0 -110
- data/examples/v201302/targeting/get_targetable_languages_and_carriers.rb +0 -94
- data/examples/v201302/targeting/lookup_location.rb +0 -112
- data/examples/v201309/campaign_management/add_location_extension_override.rb +0 -91
- data/examples/v201309/reporting/get_campaign_stats.rb +0 -113
- data/lib/adwords_api/v201302/ad_extension_override_service.rb +0 -38
- data/lib/adwords_api/v201302/ad_extension_override_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/ad_group_ad_service.rb +0 -42
- data/lib/adwords_api/v201302/ad_group_ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/ad_group_bid_modifier_service.rb +0 -38
- data/lib/adwords_api/v201302/ad_group_bid_modifier_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/ad_group_criterion_service.rb +0 -42
- data/lib/adwords_api/v201302/ad_group_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/ad_group_feed_service.rb +0 -38
- data/lib/adwords_api/v201302/ad_group_feed_service_registry.rb +0 -47
- data/lib/adwords_api/v201302/ad_group_service.rb +0 -42
- data/lib/adwords_api/v201302/ad_group_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/ad_param_service.rb +0 -38
- data/lib/adwords_api/v201302/ad_param_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/alert_service.rb +0 -34
- data/lib/adwords_api/v201302/alert_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/budget_order_service.rb +0 -42
- data/lib/adwords_api/v201302/budget_order_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/budget_service.rb +0 -38
- data/lib/adwords_api/v201302/budget_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/campaign_ad_extension_service.rb +0 -38
- data/lib/adwords_api/v201302/campaign_ad_extension_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/campaign_criterion_service.rb +0 -42
- data/lib/adwords_api/v201302/campaign_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/campaign_feed_service.rb +0 -38
- data/lib/adwords_api/v201302/campaign_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/campaign_service.rb +0 -42
- data/lib/adwords_api/v201302/campaign_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/campaign_shared_set_service.rb +0 -38
- data/lib/adwords_api/v201302/campaign_shared_set_service_registry.rb +0 -47
- data/lib/adwords_api/v201302/constant_data_service.rb +0 -62
- data/lib/adwords_api/v201302/constant_data_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/conversion_tracker_service.rb +0 -38
- data/lib/adwords_api/v201302/conversion_tracker_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/customer_service.rb +0 -34
- data/lib/adwords_api/v201302/customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/customer_sync_service.rb +0 -34
- data/lib/adwords_api/v201302/customer_sync_service_registry.rb +0 -47
- data/lib/adwords_api/v201302/data_service.rb +0 -38
- data/lib/adwords_api/v201302/data_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/experiment_service.rb +0 -38
- data/lib/adwords_api/v201302/experiment_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/feed_item_service.rb +0 -38
- data/lib/adwords_api/v201302/feed_item_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/feed_mapping_service.rb +0 -38
- data/lib/adwords_api/v201302/feed_mapping_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/feed_service.rb +0 -38
- data/lib/adwords_api/v201302/feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/geo_location_service.rb +0 -34
- data/lib/adwords_api/v201302/geo_location_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/location_criterion_service.rb +0 -34
- data/lib/adwords_api/v201302/location_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/managed_customer_service.rb +0 -50
- data/lib/adwords_api/v201302/managed_customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/media_service.rb +0 -38
- data/lib/adwords_api/v201302/media_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/mutate_job_service.rb +0 -42
- data/lib/adwords_api/v201302/mutate_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/report_definition_service.rb +0 -34
- data/lib/adwords_api/v201302/report_definition_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/shared_criterion_service.rb +0 -38
- data/lib/adwords_api/v201302/shared_criterion_service_registry.rb +0 -47
- data/lib/adwords_api/v201302/shared_set_service.rb +0 -38
- data/lib/adwords_api/v201302/shared_set_service_registry.rb +0 -47
- data/lib/adwords_api/v201302/targeting_idea_service.rb +0 -38
- data/lib/adwords_api/v201302/targeting_idea_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/traffic_estimator_service.rb +0 -34
- data/lib/adwords_api/v201302/traffic_estimator_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/user_list_service.rb +0 -38
- data/lib/adwords_api/v201302/user_list_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/video_ad_service.rb +0 -38
- data/lib/adwords_api/v201302/video_ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/video_campaign_criterion_service.rb +0 -38
- data/lib/adwords_api/v201302/video_campaign_criterion_service_registry.rb +0 -47
- data/lib/adwords_api/v201302/video_campaign_service.rb +0 -38
- data/lib/adwords_api/v201302/video_campaign_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/video_service.rb +0 -42
- data/lib/adwords_api/v201302/video_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/video_targeting_group_criterion_service.rb +0 -38
- data/lib/adwords_api/v201302/video_targeting_group_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201302/video_targeting_group_service.rb +0 -38
- data/lib/adwords_api/v201302/video_targeting_group_service_registry.rb +0 -46
- data/test/examples/v201302/test_account_management.rb +0 -50
- data/test/examples/v201302/test_advanced_operations.rb +0 -81
- data/test/examples/v201302/test_basic_operations.rb +0 -177
- data/test/examples/v201302/test_campaign_management.rb +0 -132
- data/test/examples/v201302/test_error_handling.rb +0 -63
- data/test/examples/v201302/test_migration.rb +0 -49
- data/test/examples/v201302/test_misc.rb +0 -39
- data/test/examples/v201302/test_optimization.rb +0 -63
- data/test/examples/v201302/test_remarketing.rb +0 -39
- data/test/examples/v201302/test_reporting.rb +0 -84
- data/test/examples/v201302/test_targeting.rb +0 -68
- data/test/examples/v201302/utils.rb +0 -267
- data/test/suite_exampletests_v201302.rb +0 -37
- data/test/templates/v201302/basic_operations_get_campaigns.def +0 -114
- data/test/templates/v201302/misc_use_oauth2_jwt.def +0 -131
|
@@ -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 2013, 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 video campaign.
|
|
22
|
-
#
|
|
23
|
-
# Note: AdWords for Video API is a Beta feature.
|
|
24
|
-
#
|
|
25
|
-
# Tags: VideoCampaignService.mutate, BudgetService.mutate
|
|
26
|
-
|
|
27
|
-
require 'adwords_api'
|
|
28
|
-
require 'date'
|
|
29
|
-
|
|
30
|
-
def add_video_campaign()
|
|
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
|
-
budget_srv = adwords.service(:BudgetService, API_VERSION)
|
|
40
|
-
video_campaign_srv = adwords.service(:VideoCampaignService, API_VERSION)
|
|
41
|
-
|
|
42
|
-
# Create a budget, which can be shared by multiple campaigns.
|
|
43
|
-
budget = {
|
|
44
|
-
:name => 'Video budget #%d' % (Time.new.to_f * 1000).to_i,
|
|
45
|
-
:amount => {:micro_amount => 50000000},
|
|
46
|
-
:delivery_method => 'STANDARD',
|
|
47
|
-
:period => 'DAILY'
|
|
48
|
-
}
|
|
49
|
-
budget_operation = {:operator => 'ADD', :operand => budget}
|
|
50
|
-
|
|
51
|
-
# Add budget.
|
|
52
|
-
return_budget = budget_srv.mutate([budget_operation])
|
|
53
|
-
budget_id = return_budget[:value].first[:budget_id]
|
|
54
|
-
|
|
55
|
-
# Create video campaign.
|
|
56
|
-
campaigns = [{
|
|
57
|
-
:name => "Interplanetary Video #%d" % (Time.new.to_f * 1000).to_i,
|
|
58
|
-
:status => 'PAUSED',
|
|
59
|
-
:budget_id => budget_id,
|
|
60
|
-
# Optional fields:
|
|
61
|
-
:start_date =>
|
|
62
|
-
DateTime.parse((Date.today + 1).to_s).strftime('%Y%m%d'),
|
|
63
|
-
}]
|
|
64
|
-
|
|
65
|
-
# Prepare for adding campaign.
|
|
66
|
-
operations = campaigns.map do |campaign|
|
|
67
|
-
{:operator => 'ADD', :operand => campaign}
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# Add video campaign.
|
|
71
|
-
response = video_campaign_srv.mutate(operations)
|
|
72
|
-
if response and response[:value]
|
|
73
|
-
response[:value].each do |campaign|
|
|
74
|
-
puts "Campaign with name '%s' and ID %d was added." %
|
|
75
|
-
[campaign[:name], campaign[:id]]
|
|
76
|
-
end
|
|
77
|
-
else
|
|
78
|
-
raise new StandardError, 'No campaigns were added.'
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
if __FILE__ == $0
|
|
83
|
-
API_VERSION = :v201302
|
|
84
|
-
|
|
85
|
-
begin
|
|
86
|
-
add_video_campaign()
|
|
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,92 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# Encoding: utf-8
|
|
3
|
-
#
|
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
|
5
|
-
#
|
|
6
|
-
# Copyright:: Copyright 2013, 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 find YouTube videos by a search string. It
|
|
22
|
-
# retrieve details for the first 100 matching videos.
|
|
23
|
-
#
|
|
24
|
-
# Note: AdWords for Video API is a Beta feature.
|
|
25
|
-
#
|
|
26
|
-
# Tags: VideoService.search
|
|
27
|
-
|
|
28
|
-
require 'adwords_api'
|
|
29
|
-
|
|
30
|
-
def find_videos()
|
|
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
|
-
video_srv = adwords.service(:VideoService, API_VERSION)
|
|
40
|
-
|
|
41
|
-
# Search string to use.
|
|
42
|
-
query_str = 'AdWords API with Ruby'
|
|
43
|
-
|
|
44
|
-
# Create a selector.
|
|
45
|
-
selector = {
|
|
46
|
-
:search_type => 'VIDEO',
|
|
47
|
-
:query => query_str,
|
|
48
|
-
:paging => {
|
|
49
|
-
:start_index => 0,
|
|
50
|
-
:number_results => PAGE_SIZE
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
# Run the query.
|
|
55
|
-
page = video_srv.search(selector)
|
|
56
|
-
|
|
57
|
-
if page[:entries]
|
|
58
|
-
page[:entries].each do |video|
|
|
59
|
-
puts "YouTube video ID '%s' with title '%s' found." %
|
|
60
|
-
[video[:id], video[:title]]
|
|
61
|
-
end
|
|
62
|
-
if page.include?(:total_num_entries)
|
|
63
|
-
puts "\tTotal number of matching videos: %d." % [page[:total_num_entries]]
|
|
64
|
-
end
|
|
65
|
-
else
|
|
66
|
-
puts "No videos matching '%s' were found." % query_str
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
if __FILE__ == $0
|
|
71
|
-
API_VERSION = :v201302
|
|
72
|
-
PAGE_SIZE = 100
|
|
73
|
-
|
|
74
|
-
begin
|
|
75
|
-
find_videos()
|
|
76
|
-
|
|
77
|
-
# HTTP errors.
|
|
78
|
-
rescue AdsCommon::Errors::HttpError => e
|
|
79
|
-
puts "HTTP Error: %s" % e
|
|
80
|
-
|
|
81
|
-
# API errors.
|
|
82
|
-
rescue AdwordsApi::Errors::ApiException => e
|
|
83
|
-
puts "Message: %s" % e.message
|
|
84
|
-
puts 'Errors:'
|
|
85
|
-
e.errors.each_with_index do |error, index|
|
|
86
|
-
puts "\tError [%d]:" % (index + 1)
|
|
87
|
-
error.each do |field, value|
|
|
88
|
-
puts "\t\t%s: %s" % [field, value]
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# Encoding: utf-8
|
|
3
|
-
#
|
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
|
5
|
-
#
|
|
6
|
-
# Copyright:: Copyright 2013, 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 show how to retrieve all keywords for a video campaign. To get
|
|
22
|
-
# a list with all campaigns, run get_video_campaigns.rb.
|
|
23
|
-
#
|
|
24
|
-
# Note: AdWords for Video API is a Beta feature.
|
|
25
|
-
#
|
|
26
|
-
# Tags: VideoTargetingGroupCriterionService.get
|
|
27
|
-
|
|
28
|
-
require 'adwords_api'
|
|
29
|
-
|
|
30
|
-
def get_keyword_criteria(campaign_id)
|
|
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
|
-
vtgc_srv =
|
|
40
|
-
adwords.service(:VideoTargetingGroupCriterionService, API_VERSION)
|
|
41
|
-
|
|
42
|
-
# Get all the keywords for the campaign.
|
|
43
|
-
selector = {
|
|
44
|
-
:campaign_ids => [campaign_id],
|
|
45
|
-
:criterion_types => ['SEARCH_KEYWORD'],
|
|
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 = vtgc_srv.get(selector)
|
|
57
|
-
if page[:entries]
|
|
58
|
-
page[:entries].each do |keyword|
|
|
59
|
-
negative_string =
|
|
60
|
-
('NegativeTargetingGroupCriterion'.eql?(keyword[:xsi_type])) ?
|
|
61
|
-
' (negative)' : ''
|
|
62
|
-
puts "Criterion%s ID %d, targeting group ID %d and text '%s'" %
|
|
63
|
-
[negative_string, keyword[:criterion][:id],
|
|
64
|
-
keyword[:targeting_group_id], keyword[: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 "\tTotal number of keywords found: %d." % [page[:total_num_entries]]
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
if __FILE__ == $0
|
|
78
|
-
API_VERSION = :v201302
|
|
79
|
-
PAGE_SIZE = 500
|
|
80
|
-
|
|
81
|
-
begin
|
|
82
|
-
# Campaign ID to get criteria for.
|
|
83
|
-
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
|
84
|
-
get_keyword_criteria(campaign_id)
|
|
85
|
-
|
|
86
|
-
# HTTP errors.
|
|
87
|
-
rescue AdsCommon::Errors::HttpError => e
|
|
88
|
-
puts "HTTP Error: %s" % e
|
|
89
|
-
|
|
90
|
-
# API errors.
|
|
91
|
-
rescue AdwordsApi::Errors::ApiException => e
|
|
92
|
-
puts "Message: %s" % e.message
|
|
93
|
-
puts 'Errors:'
|
|
94
|
-
e.errors.each_with_index do |error, index|
|
|
95
|
-
puts "\tError [%d]:" % (index + 1)
|
|
96
|
-
error.each do |field, value|
|
|
97
|
-
puts "\t\t%s: %s" % [field, value]
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# Encoding: utf-8
|
|
3
|
-
#
|
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
|
5
|
-
#
|
|
6
|
-
# Copyright:: Copyright 2013, 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 show how to retrieve all targeting groups for an account.
|
|
22
|
-
#
|
|
23
|
-
# Note: AdWords for Video API is a Beta feature.
|
|
24
|
-
#
|
|
25
|
-
# Tags: VideoTargetingGroupService.get
|
|
26
|
-
|
|
27
|
-
require 'adwords_api'
|
|
28
|
-
|
|
29
|
-
def get_targeting_groups()
|
|
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
|
-
video_targeting_group_srv =
|
|
39
|
-
adwords.service(:VideoTargetingGroupService, API_VERSION)
|
|
40
|
-
|
|
41
|
-
# Get all targeting groups for this account.
|
|
42
|
-
selector = {
|
|
43
|
-
:paging => {
|
|
44
|
-
:start_index => 0,
|
|
45
|
-
:number_results => PAGE_SIZE
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
# Set initial values.
|
|
50
|
-
offset, page = 0, {}
|
|
51
|
-
|
|
52
|
-
begin
|
|
53
|
-
page = video_targeting_group_srv.get(selector)
|
|
54
|
-
if page[:entries]
|
|
55
|
-
page[:entries].each do |group|
|
|
56
|
-
puts "Targeting group ID %d, campaign ID %d and name '%s'" %
|
|
57
|
-
[group[:id], group[:campaign_id], group[:name]]
|
|
58
|
-
end
|
|
59
|
-
# Increment values to request the next page.
|
|
60
|
-
offset += PAGE_SIZE
|
|
61
|
-
selector[:paging][:start_index] = offset
|
|
62
|
-
end
|
|
63
|
-
end while page[:total_num_entries] > offset
|
|
64
|
-
|
|
65
|
-
if page.include?(:total_num_entries)
|
|
66
|
-
puts "\tTotal number of targeting groups found: %d." %
|
|
67
|
-
[page[:total_num_entries]]
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
if __FILE__ == $0
|
|
72
|
-
API_VERSION = :v201302
|
|
73
|
-
PAGE_SIZE = 500
|
|
74
|
-
|
|
75
|
-
begin
|
|
76
|
-
get_targeting_groups()
|
|
77
|
-
|
|
78
|
-
# HTTP errors.
|
|
79
|
-
rescue AdsCommon::Errors::HttpError => e
|
|
80
|
-
puts "HTTP Error: %s" % e
|
|
81
|
-
|
|
82
|
-
# API errors.
|
|
83
|
-
rescue AdwordsApi::Errors::ApiException => e
|
|
84
|
-
puts "Message: %s" % e.message
|
|
85
|
-
puts 'Errors:'
|
|
86
|
-
e.errors.each_with_index do |error, index|
|
|
87
|
-
puts "\tError [%d]:" % (index + 1)
|
|
88
|
-
error.each do |field, value|
|
|
89
|
-
puts "\t\t%s: %s" % [field, value]
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
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 2013, 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 demonstrates how to retrieve all campaign-level criteria.
|
|
22
|
-
#
|
|
23
|
-
# Note: AdWords for Video API is a Beta feature.
|
|
24
|
-
#
|
|
25
|
-
# Tags: VideoCampaignCriterionService.get
|
|
26
|
-
|
|
27
|
-
require 'adwords_api'
|
|
28
|
-
|
|
29
|
-
def get_video_campaign_criteria(campaign_id)
|
|
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
|
-
vtgc_srv =
|
|
39
|
-
adwords.service(:VideoCampaignCriterionService, API_VERSION)
|
|
40
|
-
|
|
41
|
-
# Get all criteria for the campaign.
|
|
42
|
-
selector = {
|
|
43
|
-
:campaign_ids => [campaign_id],
|
|
44
|
-
:paging => {
|
|
45
|
-
:start_index => 0,
|
|
46
|
-
:number_results => PAGE_SIZE
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
# Set initial values.
|
|
51
|
-
offset, page = 0, {}
|
|
52
|
-
|
|
53
|
-
begin
|
|
54
|
-
page = vtgc_srv.get(selector)
|
|
55
|
-
if page[:entries]
|
|
56
|
-
page[:entries].each do |criterion|
|
|
57
|
-
negative_str =
|
|
58
|
-
(criterion[:xsi_type] == 'NegativeVideoCampaignCriterion') ?
|
|
59
|
-
' negative' : ''
|
|
60
|
-
puts "Video%s criterion ID %d or type '%s'" % [negative_str,
|
|
61
|
-
criterion[:criterion][:id], criterion[:criterion][:xsi_type]]
|
|
62
|
-
end
|
|
63
|
-
# Increment values to request the next page.
|
|
64
|
-
offset += PAGE_SIZE
|
|
65
|
-
selector[:paging][:start_index] = offset
|
|
66
|
-
end
|
|
67
|
-
end while page[:total_num_entries] > offset
|
|
68
|
-
|
|
69
|
-
if page.include?(:total_num_entries)
|
|
70
|
-
puts "\tTotal number of criteria found: %d." % [page[:total_num_entries]]
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
if __FILE__ == $0
|
|
75
|
-
API_VERSION = :v201302
|
|
76
|
-
PAGE_SIZE = 500
|
|
77
|
-
|
|
78
|
-
begin
|
|
79
|
-
# Campaign ID to get criteria for.
|
|
80
|
-
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
|
81
|
-
|
|
82
|
-
get_video_campaign_criteria(campaign_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
|