google-adwords-api 0.9.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/README +4 -4
- data/examples/{v201209 → v201309}/account_management/create_account.rb +9 -1
- data/examples/{v201209 → v201309}/account_management/get_account_alerts.rb +9 -1
- data/examples/{v201209 → v201309}/account_management/get_account_changes.rb +9 -1
- data/examples/{v201209 → v201309}/account_management/get_account_hierarchy.rb +9 -1
- data/examples/v201309/advanced_operations/add_ad_group_bid_modifier.rb +105 -0
- data/examples/v201309/advanced_operations/add_click_to_download_ad.rb +137 -0
- data/examples/v201309/advanced_operations/add_site_links.rb +244 -0
- data/examples/v201309/advanced_operations/create_and_attach_shared_keyword_set.rb +147 -0
- data/examples/v201309/advanced_operations/find_and_remove_criteria_from_shared_set.rb +181 -0
- data/examples/{v201209/adwords_for_video/get_video_campaign_criteria.rb → v201309/advanced_operations/get_ad_group_bid_modifiers.rb} +30 -23
- data/examples/v201309/advanced_operations/upload_offline_conversions.rb +117 -0
- data/examples/v201309/advanced_operations/use_shared_bidding_strategy.rb +163 -0
- data/examples/{v201209 → v201309}/basic_operations/add_ad_groups.rb +28 -21
- data/examples/{v201209 → v201309}/basic_operations/add_campaigns.rb +18 -15
- data/examples/{v201209 → v201309}/basic_operations/add_keywords.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/add_text_ads.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/delete_ad.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/delete_ad_group.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/delete_campaign.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/delete_keyword.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/get_ad_groups.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/get_campaigns.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/get_campaigns_with_awql.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/get_keywords.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/get_text_ads.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/pause_ad.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/update_ad_group.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/update_campaign.rb +9 -1
- data/examples/{v201209 → v201309}/basic_operations/update_keyword.rb +21 -10
- data/examples/{v201209 → v201309}/campaign_management/add_experiment.rb +9 -1
- data/examples/{v201209 → v201309}/campaign_management/add_keywords_in_bulk.rb +10 -2
- data/examples/{v201209 → v201309}/campaign_management/add_location_extension.rb +9 -1
- data/examples/{v201209 → v201309}/campaign_management/add_location_extension_override.rb +9 -1
- data/examples/{v201209 → v201309}/campaign_management/get_all_disapproved_ads.rb +21 -13
- data/examples/{v201209 → v201309}/campaign_management/get_all_disapproved_ads_with_awql.rb +17 -8
- data/examples/{v201209 → v201309}/campaign_management/promote_experiment.rb +9 -1
- data/examples/{v201209 → v201309}/campaign_management/set_ad_parameters.rb +9 -1
- data/examples/{v201209 → v201309}/campaign_management/set_criterion_bid_modifier.rb +11 -5
- data/examples/{v201209 → v201309}/campaign_management/validate_text_ad.rb +9 -1
- data/examples/{v201209 → v201309}/error_handling/handle_captcha_challenge.rb +1 -1
- data/examples/{v201209 → v201309}/error_handling/handle_partial_failures.rb +9 -1
- data/examples/{v201209 → v201309}/error_handling/handle_policy_violation_error.rb +9 -1
- data/examples/{v201209 → v201309}/error_handling/handle_two_factor_authorization_error.rb +1 -1
- data/examples/{v201209 → v201309}/misc/get_all_images_and_videos.rb +9 -1
- data/examples/{v201209/misc/use_oauth2.rb → v201309/misc/setup_oauth2.rb} +17 -26
- data/examples/{v201209 → v201309}/misc/upload_image.rb +9 -1
- data/examples/{v201209 → v201309}/misc/use_oauth2_jwt.rb +1 -1
- data/examples/{v201209 → v201309}/optimization/estimate_keyword_traffic.rb +9 -1
- data/examples/{v201209 → v201309}/optimization/get_keyword_bid_simulations.rb +9 -1
- data/examples/{v201209 → v201309}/optimization/get_keyword_ideas.rb +17 -1
- data/examples/{v201209 → v201309}/optimization/get_placement_ideas.rb +9 -1
- data/examples/{v201209 → v201309}/remarketing/add_audience.rb +11 -3
- data/examples/{v201209 → v201309}/remarketing/add_conversion_tracker.rb +9 -2
- data/examples/{v201209 → v201309}/reporting/download_criteria_report.rb +9 -1
- data/examples/{v201209 → v201309}/reporting/download_criteria_report_with_awql.rb +9 -1
- data/examples/{v201209 → v201309}/reporting/get_campaign_stats.rb +9 -1
- data/examples/{v201209 → v201309}/reporting/get_report_fields.rb +9 -1
- data/examples/{v201209 → v201309}/reporting/parallel_report_download.rb +9 -1
- data/examples/{v201209 → v201309}/targeting/add_campaign_targeting_criteria.rb +10 -5
- data/examples/{v201209 → v201309}/targeting/add_demographic_targeting_criteria.rb +9 -1
- data/examples/{v201209 → v201309}/targeting/get_campaign_targeting_criteria.rb +9 -1
- data/examples/{v201209 → v201309}/targeting/get_targetable_languages_and_carriers.rb +9 -1
- data/examples/{v201209 → v201309}/targeting/lookup_location.rb +9 -1
- data/lib/adwords_api/api_config.rb +57 -55
- data/lib/adwords_api/{v201209 → v201309}/ad_group_ad_service.rb +7 -7
- data/lib/adwords_api/v201309/ad_group_ad_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/ad_group_bid_modifier_service.rb +6 -6
- data/lib/adwords_api/v201309/ad_group_bid_modifier_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/ad_group_criterion_service.rb +7 -7
- data/lib/adwords_api/v201309/ad_group_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/v201309/ad_group_feed_service.rb +38 -0
- data/lib/adwords_api/v201309/ad_group_feed_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/ad_group_service.rb +7 -7
- data/lib/adwords_api/v201309/ad_group_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/ad_param_service.rb +7 -7
- data/lib/adwords_api/v201309/ad_param_service_registry.rb +46 -0
- data/lib/adwords_api/v201309/adwords_user_list_service.rb +38 -0
- data/lib/adwords_api/v201309/adwords_user_list_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/alert_service.rb +7 -7
- data/lib/adwords_api/v201309/alert_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209/managed_customer_service.rb → v201309/bidding_strategy_service.rb} +9 -9
- data/lib/adwords_api/v201309/bidding_strategy_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/budget_order_service.rb +7 -7
- data/lib/adwords_api/v201309/budget_order_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/budget_service.rb +7 -7
- data/lib/adwords_api/v201309/budget_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/campaign_ad_extension_service.rb +7 -7
- data/lib/adwords_api/v201309/campaign_ad_extension_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/campaign_criterion_service.rb +7 -7
- data/lib/adwords_api/v201309/campaign_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/v201309/campaign_feed_service.rb +38 -0
- data/lib/adwords_api/v201309/campaign_feed_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/campaign_service.rb +7 -7
- data/lib/adwords_api/v201309/campaign_service_registry.rb +46 -0
- data/lib/adwords_api/v201309/campaign_shared_set_service.rb +38 -0
- data/lib/adwords_api/v201309/campaign_shared_set_service_registry.rb +47 -0
- data/lib/adwords_api/{v201209 → v201309}/constant_data_service.rb +7 -7
- data/lib/adwords_api/v201309/constant_data_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/conversion_tracker_service.rb +7 -7
- data/lib/adwords_api/v201309/conversion_tracker_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/customer_service.rb +7 -7
- data/lib/adwords_api/v201309/customer_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/customer_sync_service.rb +7 -7
- data/lib/adwords_api/v201309/customer_sync_service_registry.rb +47 -0
- data/lib/adwords_api/{v201209 → v201309}/data_service.rb +7 -7
- data/lib/adwords_api/v201309/data_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/experiment_service.rb +7 -7
- data/lib/adwords_api/v201309/experiment_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209/user_list_service.rb → v201309/feed_item_service.rb} +9 -9
- data/lib/adwords_api/v201309/feed_item_service_registry.rb +46 -0
- data/lib/adwords_api/v201309/feed_mapping_service.rb +38 -0
- data/lib/adwords_api/v201309/feed_mapping_service_registry.rb +46 -0
- data/lib/adwords_api/v201309/feed_service.rb +38 -0
- data/lib/adwords_api/v201309/feed_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/geo_location_service.rb +7 -7
- data/lib/adwords_api/v201309/geo_location_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/location_criterion_service.rb +7 -7
- data/lib/adwords_api/v201309/location_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/v201309/managed_customer_service.rb +50 -0
- data/lib/adwords_api/v201309/managed_customer_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/media_service.rb +7 -7
- data/lib/adwords_api/v201309/media_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/mutate_job_service.rb +7 -7
- data/lib/adwords_api/v201309/mutate_job_service_registry.rb +46 -0
- data/lib/adwords_api/v201309/offline_conversion_feed_service.rb +34 -0
- data/lib/adwords_api/v201309/offline_conversion_feed_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/report_definition_service.rb +7 -7
- data/lib/adwords_api/v201309/report_definition_service_registry.rb +46 -0
- data/lib/adwords_api/v201309/shared_criterion_service.rb +38 -0
- data/lib/adwords_api/v201309/shared_criterion_service_registry.rb +47 -0
- data/lib/adwords_api/v201309/shared_set_service.rb +38 -0
- data/lib/adwords_api/v201309/shared_set_service_registry.rb +47 -0
- data/lib/adwords_api/{v201209 → v201309}/targeting_idea_service.rb +7 -7
- data/lib/adwords_api/v201309/targeting_idea_service_registry.rb +46 -0
- data/lib/adwords_api/{v201209 → v201309}/traffic_estimator_service.rb +7 -7
- data/lib/adwords_api/{v201209 → v201309}/traffic_estimator_service_registry.rb +5 -5
- data/lib/adwords_api/version.rb +1 -1
- data/test/adwords_api/test_adwords_api.rb +1 -1
- data/test/adwords_api/test_api_config.rb +8 -8
- data/test/adwords_api/test_report_utils.rb +1 -1
- data/test/bugs/test_issue_00000031.rb +2 -2
- data/test/bugs/test_issue_00000063.rb +6 -6
- data/test/templates/v201302/basic_operations_get_campaigns.def +1 -1
- data/test/templates/v201302/misc_use_oauth2_jwt.def +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/{v201209 → v201309}/basic_operations_get_campaigns.def +7 -7
- data/test/templates/v201309/misc_use_oauth2_jwt.def +131 -0
- metadata +416 -430
- data/examples/v201209/account_management/get_client_customer_id.rb +0 -88
- data/examples/v201209/account_management/get_client_unit_usage.rb +0 -90
- data/examples/v201209/adwords_for_video/add_video_campaign.rb +0 -103
- data/examples/v201209/adwords_for_video/find_videos.rb +0 -92
- data/examples/v201209/adwords_for_video/get_keyword_criteria.rb +0 -101
- data/examples/v201209/adwords_for_video/get_targeting_groups.rb +0 -93
- data/examples/v201209/adwords_for_video/get_video_campaign_stats.rb +0 -126
- data/examples/v201209/adwords_for_video/get_video_campaigns.rb +0 -94
- data/examples/v201209/campaign_management/set_campaign_enhanced.rb +0 -89
- data/lib/adwords_api/v201209/ad_extension_override_service.rb +0 -38
- data/lib/adwords_api/v201209/ad_extension_override_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/ad_group_ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/ad_group_bid_modifier_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/ad_group_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/ad_group_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/ad_param_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/alert_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/budget_order_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/budget_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/campaign_ad_extension_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/campaign_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/campaign_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/constant_data_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/conversion_tracker_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/customer_sync_service_registry.rb +0 -47
- data/lib/adwords_api/v201209/data_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/experiment_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/geo_location_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/info_service.rb +0 -34
- data/lib/adwords_api/v201209/info_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/location_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/managed_customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/media_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/mutate_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/report_definition_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/targeting_idea_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/user_list_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/video_ad_service.rb +0 -38
- data/lib/adwords_api/v201209/video_ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/video_campaign_criterion_service.rb +0 -38
- data/lib/adwords_api/v201209/video_campaign_criterion_service_registry.rb +0 -47
- data/lib/adwords_api/v201209/video_campaign_service.rb +0 -38
- data/lib/adwords_api/v201209/video_campaign_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/video_service.rb +0 -42
- data/lib/adwords_api/v201209/video_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/video_targeting_group_criterion_service.rb +0 -38
- data/lib/adwords_api/v201209/video_targeting_group_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201209/video_targeting_group_service.rb +0 -38
- data/lib/adwords_api/v201209/video_targeting_group_service_registry.rb +0 -46
- data/test/examples/v201209/test_account_management.rb +0 -60
- data/test/examples/v201209/test_basic_operations.rb +0 -177
- data/test/examples/v201209/test_campaign_management.rb +0 -124
- data/test/examples/v201209/test_error_handling.rb +0 -63
- data/test/examples/v201209/test_misc.rb +0 -39
- data/test/examples/v201209/test_optimization.rb +0 -63
- data/test/examples/v201209/test_remarketing.rb +0 -39
- data/test/examples/v201209/test_reporting.rb +0 -84
- data/test/examples/v201209/test_targeting.rb +0 -60
- data/test/examples/v201209/utils.rb +0 -261
- data/test/suite_exampletests_v201209.rb +0 -37
- data/test/suite_exampletests_v201306.rb +0 -37
@@ -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 find a client customer ID for a client email.
|
22
|
-
# We recommend to use this script as a one off to convert your identifiers to
|
23
|
-
# IDs and store them for future use.
|
24
|
-
#
|
25
|
-
# Note: This code example uses MCC-level calls and won't work with Test
|
26
|
-
# Accounts, see: https://developers.google.com/adwords/api/docs/test-accounts
|
27
|
-
#
|
28
|
-
# Tags: InfoService.get
|
29
|
-
|
30
|
-
require 'adwords_api'
|
31
|
-
require 'adwords_api/utils'
|
32
|
-
|
33
|
-
def get_client_customer_id(client_email)
|
34
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
35
|
-
# when called without parameters.
|
36
|
-
adwords = AdwordsApi::Api.new
|
37
|
-
|
38
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
39
|
-
# the configuration file or provide your own logger:
|
40
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
41
|
-
|
42
|
-
info_srv = adwords.service(:InfoService, API_VERSION)
|
43
|
-
|
44
|
-
today = Time.new.strftime('%Y%m%d')
|
45
|
-
selector = {
|
46
|
-
:client_emails => [client_email],
|
47
|
-
:api_usage_type => 'UNIT_COUNT_FOR_CLIENTS',
|
48
|
-
:include_sub_accounts => true,
|
49
|
-
:date_range => {:min => today, :max => today}
|
50
|
-
}
|
51
|
-
|
52
|
-
# Get the information for client email address.
|
53
|
-
info = adwords.use_mcc() {info_srv.get(selector)}
|
54
|
-
|
55
|
-
if info and info[:api_usage_records]
|
56
|
-
api_usage_records = info[:api_usage_records]
|
57
|
-
api_usage_records.each do |record|
|
58
|
-
puts "Found record with client email '%s' and ID %s." %
|
59
|
-
[record[:client_email],
|
60
|
-
AdwordsApi::Utils.format_id(record[:client_customer_id])]
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
if __FILE__ == $0
|
66
|
-
API_VERSION = :v201209
|
67
|
-
|
68
|
-
begin
|
69
|
-
# Email address to find ID for.
|
70
|
-
client_email = 'INSERT_EMAIL_ADDRESS_HERE'
|
71
|
-
get_client_customer_id(client_email)
|
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
|
@@ -1,90 +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 the number of API units usage for a
|
22
|
-
# client account for the current month.
|
23
|
-
#
|
24
|
-
# Note: This code example uses MCC-level calls and won't work with Test
|
25
|
-
# Accounts, see: https://developers.google.com/adwords/api/docs/test-accounts
|
26
|
-
#
|
27
|
-
# Tags: InfoService.get
|
28
|
-
|
29
|
-
require 'adwords_api'
|
30
|
-
|
31
|
-
def get_client_unit_usage(client_customer_id)
|
32
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
33
|
-
# when called without parameters.
|
34
|
-
adwords = AdwordsApi::Api.new
|
35
|
-
|
36
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
37
|
-
# the configuration file or provide your own logger:
|
38
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
39
|
-
|
40
|
-
info_srv = adwords.service(:InfoService, API_VERSION)
|
41
|
-
|
42
|
-
start_date = Time.now.strftime('%Y%m01')
|
43
|
-
end_date = Time.now.strftime('%Y%m%d')
|
44
|
-
|
45
|
-
selector = {
|
46
|
-
:api_usage_type => 'UNIT_COUNT_FOR_CLIENTS',
|
47
|
-
:client_customer_ids => [client_customer_id],
|
48
|
-
# Set to true to navigate your entire accounts tree.
|
49
|
-
:include_sub_accounts => 1,
|
50
|
-
:date_range => {
|
51
|
-
:min => start_date,
|
52
|
-
:max => end_date
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
# Force to use the MCC credentials.
|
57
|
-
adwords.use_mcc do
|
58
|
-
# Get the unit info.
|
59
|
-
info_srv.get(selector) do |header, response|
|
60
|
-
puts "Total number of units consumed from %s to %s is %d." %
|
61
|
-
[start_date, end_date, response[:cost]]
|
62
|
-
puts "Number of units consumed by this request is %d" % header[:units]
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
if __FILE__ == $0
|
68
|
-
API_VERSION = :v201209
|
69
|
-
|
70
|
-
begin
|
71
|
-
# Specify client customer ID for the account to get usage for.
|
72
|
-
client_customer_id = 'INSERT_CLIENT_CUSTOMER_ID_HERE'.to_i
|
73
|
-
get_client_unit_usage(client_customer_id)
|
74
|
-
|
75
|
-
# HTTP errors.
|
76
|
-
rescue AdsCommon::Errors::HttpError => e
|
77
|
-
puts "HTTP Error: %s" % e
|
78
|
-
|
79
|
-
# API errors.
|
80
|
-
rescue AdwordsApi::Errors::ApiException => e
|
81
|
-
puts "Message: %s" % e.message
|
82
|
-
puts 'Errors:'
|
83
|
-
e.errors.each_with_index do |error, index|
|
84
|
-
puts "\tError [%d]:" % (index + 1)
|
85
|
-
error.each do |field, value|
|
86
|
-
puts "\t\t%s: %s" % [field, value]
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
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 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 = :v201209
|
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 = :v201209
|
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 = :v201209
|
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
|