google-adwords-api 0.8.2 → 0.9.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 +6 -0
- data/README +3 -3
- data/examples/{v201206/basic_operations/delete_ad_group.rb → v201209/adwords_for_video/add_video_campaign.rb} +41 -40
- data/examples/{v201206/basic_operations/pause_ad.rb → v201209/adwords_for_video/find_videos.rb} +33 -25
- data/examples/{v201206/basic_operations/get_keywords.rb → v201209/adwords_for_video/get_keyword_criteria.rb} +24 -27
- data/examples/{v201206/basic_operations/get_campaigns_with_awql.rb → v201209/adwords_for_video/get_targeting_groups.rb} +26 -18
- data/examples/{v201206/basic_operations/get_ad_groups.rb → v201209/adwords_for_video/get_video_campaign_criteria.rb} +22 -21
- data/examples/v201209/adwords_for_video/get_video_campaign_stats.rb +126 -0
- data/examples/{v201206/basic_operations/get_campaigns.rb → v201209/adwords_for_video/get_video_campaigns.rb} +16 -15
- data/examples/v201302/advanced_operations/create_and_attach_shared_keyword_set.rb +139 -0
- data/examples/v201302/advanced_operations/find_and_remove_criteria_from_shared_set.rb +173 -0
- data/lib/adwords_api/api_config.rb +17 -59
- data/lib/adwords_api/report_utils.rb +3 -19
- data/lib/adwords_api/{v201206/ad_param_service.rb → v201209/video_ad_service.rb} +8 -8
- data/lib/adwords_api/v201209/video_ad_service_registry.rb +46 -0
- data/lib/adwords_api/{v201206/campaign_ad_extension_service.rb → v201209/video_campaign_criterion_service.rb} +8 -8
- data/lib/adwords_api/v201209/video_campaign_criterion_service_registry.rb +47 -0
- data/lib/adwords_api/{v201206/bulk_mutate_job_service.rb → v201209/video_campaign_service.rb} +8 -8
- data/lib/adwords_api/v201209/video_campaign_service_registry.rb +46 -0
- data/lib/adwords_api/v201209/video_service.rb +42 -0
- data/lib/adwords_api/v201209/video_service_registry.rb +46 -0
- data/lib/adwords_api/{v201206/ad_group_ad_service.rb → v201209/video_targeting_group_criterion_service.rb} +8 -12
- data/lib/adwords_api/v201209/video_targeting_group_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/{v201206/ad_extension_override_service.rb → v201209/video_targeting_group_service.rb} +8 -8
- data/lib/adwords_api/v201209/video_targeting_group_service_registry.rb +46 -0
- data/lib/adwords_api/v201302/ad_group_feed_service.rb +1 -1
- data/lib/adwords_api/v201302/ad_group_feed_service_registry.rb +2 -2
- data/lib/adwords_api/v201302/campaign_feed_service.rb +1 -1
- data/lib/adwords_api/v201302/campaign_feed_service_registry.rb +2 -2
- data/lib/adwords_api/v201302/feed_item_service.rb +1 -1
- data/lib/adwords_api/v201302/feed_item_service_registry.rb +3 -4
- data/lib/adwords_api/v201302/feed_service.rb +1 -1
- data/lib/adwords_api/v201302/feed_service_registry.rb +4 -5
- data/lib/adwords_api/{v201206/user_list_service.rb → v201302/shared_set_service.rb} +9 -9
- data/lib/adwords_api/v201302/shared_set_service_registry.rb +47 -0
- data/lib/adwords_api/version.rb +1 -1
- data/test/adwords_api/test_report_utils.rb +0 -89
- data/test/examples/v201302/test_advanced_operations.rb +10 -0
- data/test/templates/v201209/basic_operations_get_campaigns.def +1 -1
- data/test/templates/v201302/basic_operations_get_campaigns.def +1 -1
- data/test/templates/v201302/misc_use_oauth2_jwt.def +131 -0
- data/test/test_utils.rb +6 -2
- metadata +26 -121
- data/examples/v201206/account_management/create_account.rb +0 -87
- data/examples/v201206/account_management/get_account_alerts.rb +0 -114
- data/examples/v201206/account_management/get_account_changes.rb +0 -137
- data/examples/v201206/account_management/get_account_hierarchy.rb +0 -95
- data/examples/v201206/account_management/get_client_customer_id.rb +0 -88
- data/examples/v201206/account_management/get_client_unit_usage.rb +0 -90
- data/examples/v201206/basic_operations/add_ad_groups.rb +0 -136
- data/examples/v201206/basic_operations/add_campaigns.rb +0 -151
- data/examples/v201206/basic_operations/add_keywords.rb +0 -108
- data/examples/v201206/basic_operations/add_text_ads.rb +0 -105
- data/examples/v201206/basic_operations/delete_ad.rb +0 -85
- data/examples/v201206/basic_operations/delete_campaign.rb +0 -103
- data/examples/v201206/basic_operations/delete_keyword.rb +0 -90
- data/examples/v201206/basic_operations/get_text_ads.rb +0 -106
- data/examples/v201206/basic_operations/update_ad_group.rb +0 -81
- data/examples/v201206/basic_operations/update_campaign.rb +0 -84
- data/examples/v201206/basic_operations/update_keyword.rb +0 -99
- data/examples/v201206/campaign_management/add_experiment.rb +0 -158
- data/examples/v201206/campaign_management/add_keywords_in_bulk.rb +0 -150
- data/examples/v201206/campaign_management/add_location_extension.rb +0 -117
- data/examples/v201206/campaign_management/add_location_extension_override.rb +0 -83
- data/examples/v201206/campaign_management/get_all_disapproved_ads.rb +0 -93
- data/examples/v201206/campaign_management/get_all_disapproved_ads_with_awql.rb +0 -84
- data/examples/v201206/campaign_management/promote_experiment.rb +0 -77
- data/examples/v201206/campaign_management/set_ad_parameters.rb +0 -114
- data/examples/v201206/campaign_management/validate_text_ad.rb +0 -106
- data/examples/v201206/error_handling/handle_captcha_challenge.rb +0 -93
- data/examples/v201206/error_handling/handle_partial_failures.rb +0 -126
- data/examples/v201206/error_handling/handle_policy_violation_error.rb +0 -137
- data/examples/v201206/error_handling/handle_two_factor_authorization_error.rb +0 -88
- data/examples/v201206/misc/get_all_images_and_videos.rb +0 -100
- data/examples/v201206/misc/upload_image.rb +0 -89
- data/examples/v201206/misc/use_oauth2.rb +0 -97
- data/examples/v201206/optimization/estimate_keyword_traffic.rb +0 -129
- data/examples/v201206/optimization/get_keyword_bid_simulations.rb +0 -92
- data/examples/v201206/optimization/get_keyword_ideas.rb +0 -114
- data/examples/v201206/optimization/get_placement_ideas.rb +0 -104
- data/examples/v201206/remarketing/add_audience.rb +0 -115
- data/examples/v201206/remarketing/add_conversion_tracker.rb +0 -97
- data/examples/v201206/reporting/download_criteria_report.rb +0 -79
- data/examples/v201206/reporting/download_criteria_report_with_awql.rb +0 -78
- data/examples/v201206/reporting/get_campaign_stats.rb +0 -105
- data/examples/v201206/reporting/get_report_fields.rb +0 -71
- data/examples/v201206/reporting/parallel_report_download.rb +0 -162
- data/examples/v201206/targeting/add_campaign_targeting_criteria.rb +0 -118
- data/examples/v201206/targeting/get_campaign_targeting_criteria.rb +0 -102
- data/examples/v201206/targeting/get_targetable_languages_and_carriers.rb +0 -86
- data/examples/v201206/targeting/lookup_location.rb +0 -104
- data/lib/adwords_api/v201206/ad_extension_override_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/ad_group_ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/ad_group_criterion_service.rb +0 -42
- data/lib/adwords_api/v201206/ad_group_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/ad_group_service.rb +0 -42
- data/lib/adwords_api/v201206/ad_group_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/ad_param_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/alert_service.rb +0 -34
- data/lib/adwords_api/v201206/alert_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/budget_order_service.rb +0 -42
- data/lib/adwords_api/v201206/budget_order_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/bulk_mutate_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/campaign_ad_extension_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/campaign_criterion_service.rb +0 -42
- data/lib/adwords_api/v201206/campaign_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/campaign_service.rb +0 -42
- data/lib/adwords_api/v201206/campaign_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/constant_data_service.rb +0 -62
- data/lib/adwords_api/v201206/constant_data_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/conversion_tracker_service.rb +0 -38
- data/lib/adwords_api/v201206/conversion_tracker_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/customer_service.rb +0 -34
- data/lib/adwords_api/v201206/customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/customer_sync_service.rb +0 -34
- data/lib/adwords_api/v201206/customer_sync_service_registry.rb +0 -47
- data/lib/adwords_api/v201206/data_service.rb +0 -38
- data/lib/adwords_api/v201206/data_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/experiment_service.rb +0 -38
- data/lib/adwords_api/v201206/experiment_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/geo_location_service.rb +0 -34
- data/lib/adwords_api/v201206/geo_location_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/info_service.rb +0 -34
- data/lib/adwords_api/v201206/info_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/location_criterion_service.rb +0 -34
- data/lib/adwords_api/v201206/location_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/managed_customer_service.rb +0 -38
- data/lib/adwords_api/v201206/managed_customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/media_service.rb +0 -38
- data/lib/adwords_api/v201206/media_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/mutate_job_service.rb +0 -42
- data/lib/adwords_api/v201206/mutate_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/report_definition_service.rb +0 -34
- data/lib/adwords_api/v201206/report_definition_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/targeting_idea_service.rb +0 -38
- data/lib/adwords_api/v201206/targeting_idea_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/traffic_estimator_service.rb +0 -34
- data/lib/adwords_api/v201206/traffic_estimator_service_registry.rb +0 -46
- data/lib/adwords_api/v201206/user_list_service_registry.rb +0 -46
- data/test/examples/v201206/test_account_management.rb +0 -60
- data/test/examples/v201206/test_basic_operations.rb +0 -177
- data/test/examples/v201206/test_campaign_management.rb +0 -124
- data/test/examples/v201206/test_error_handling.rb +0 -63
- data/test/examples/v201206/test_misc.rb +0 -39
- data/test/examples/v201206/test_optimization.rb +0 -63
- data/test/examples/v201206/test_remarketing.rb +0 -39
- data/test/examples/v201206/test_reporting.rb +0 -84
- data/test/examples/v201206/test_targeting.rb +0 -60
- data/test/examples/v201206/utils.rb +0 -244
- data/test/suite_exampletests_v201206.rb +0 -37
data/ChangeLog
CHANGED
data/README
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Welcome to the next generation Google-developed Ruby client library for the
|
|
4
4
|
AdWords and DoubleClick Ad Exchange Buyer API!
|
|
5
5
|
|
|
6
|
-
It contains full support for
|
|
6
|
+
It contains full support for v201209 and v201302, with full stubs, and a
|
|
7
7
|
simplified programming interface that lets you handle everything in native
|
|
8
8
|
Ruby collections.
|
|
9
9
|
|
|
@@ -58,7 +58,7 @@ You can also pass API a manually constructed config hash like:
|
|
|
58
58
|
})
|
|
59
59
|
|
|
60
60
|
Then, just specify which service you're looking to use, and which version:
|
|
61
|
-
campaign_srv = adwords.service(:CampaignService, :
|
|
61
|
+
campaign_srv = adwords.service(:CampaignService, :v201302)
|
|
62
62
|
|
|
63
63
|
and you should now be able to just use the API methods in the object you were
|
|
64
64
|
returned:
|
|
@@ -200,7 +200,7 @@ Questions can be asked on forum
|
|
|
200
200
|
|
|
201
201
|
== Licence
|
|
202
202
|
|
|
203
|
-
Copyright 2010-
|
|
203
|
+
Copyright 2010-2013, Google Inc. All Rights Reserved.
|
|
204
204
|
|
|
205
205
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
206
206
|
you may not use this file except in compliance with the License.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
|
5
5
|
#
|
|
6
|
-
# Copyright:: Copyright
|
|
6
|
+
# Copyright:: Copyright 2013, Google Inc. All Rights Reserved.
|
|
7
7
|
#
|
|
8
8
|
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
9
|
# you may not use this file except in compliance with the License.
|
|
@@ -18,14 +18,16 @@
|
|
|
18
18
|
# See the License for the specific language governing permissions and
|
|
19
19
|
# limitations under the License.
|
|
20
20
|
#
|
|
21
|
-
# This example
|
|
22
|
-
# groups, run get_ad_groups.rb.
|
|
21
|
+
# This example illustrates how to create a video campaign.
|
|
23
22
|
#
|
|
24
|
-
#
|
|
23
|
+
# Note: AdWords for Video API is a Beta feature.
|
|
24
|
+
#
|
|
25
|
+
# Tags: VideoCampaignService.mutate, BudgetService.mutate
|
|
25
26
|
|
|
26
27
|
require 'adwords_api'
|
|
28
|
+
require 'date'
|
|
27
29
|
|
|
28
|
-
def
|
|
30
|
+
def add_video_campaign()
|
|
29
31
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
30
32
|
# when called without parameters.
|
|
31
33
|
adwords = AdwordsApi::Api.new
|
|
@@ -34,55 +36,54 @@ def delete_ad_group(ad_group_id)
|
|
|
34
36
|
# the configuration file or provide your own logger:
|
|
35
37
|
# adwords.logger = Logger.new('adwords_xml.log')
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
budget_srv = adwords.service(:BudgetService, API_VERSION)
|
|
40
|
+
video_campaign_srv = adwords.service(:VideoCampaignService, API_VERSION)
|
|
38
41
|
|
|
39
|
-
#
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
:
|
|
44
|
-
:
|
|
45
|
-
{:field => 'Id', :operator => 'EQUALS', :values => [ad_group_id]}
|
|
46
|
-
]
|
|
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'
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
budget_operation = {:operator => 'ADD', :operand => budget}
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
# Add budget.
|
|
52
|
+
return_budget = budget_srv.mutate([budget_operation])
|
|
53
|
+
budget_id = return_budget[:value].first[:budget_id]
|
|
53
54
|
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
|
|
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
|
+
}]
|
|
57
64
|
|
|
58
|
-
# Prepare for
|
|
59
|
-
|
|
60
|
-
:operator => '
|
|
61
|
-
|
|
62
|
-
:id => ad_group_id,
|
|
63
|
-
:name => ad_group_name,
|
|
64
|
-
:status => 'DELETED'
|
|
65
|
-
}
|
|
66
|
-
}
|
|
65
|
+
# Prepare for adding campaign.
|
|
66
|
+
operations = campaigns.map do |campaign|
|
|
67
|
+
{:operator => 'ADD', :operand => campaign}
|
|
68
|
+
end
|
|
67
69
|
|
|
68
|
-
#
|
|
69
|
-
response =
|
|
70
|
+
# Add video campaign.
|
|
71
|
+
response = video_campaign_srv.mutate(operations)
|
|
70
72
|
if response and response[:value]
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
response[:value].each do |campaign|
|
|
74
|
+
puts "Campaign with name '%s' and ID %d was added." %
|
|
75
|
+
[campaign[:name], campaign[:id]]
|
|
76
|
+
end
|
|
74
77
|
else
|
|
75
|
-
|
|
78
|
+
raise new StandardError, 'No campaigns were added.'
|
|
76
79
|
end
|
|
77
80
|
end
|
|
78
81
|
|
|
79
82
|
if __FILE__ == $0
|
|
80
|
-
API_VERSION = :
|
|
83
|
+
API_VERSION = :v201209
|
|
81
84
|
|
|
82
85
|
begin
|
|
83
|
-
|
|
84
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
|
85
|
-
delete_ad_group(ad_group_id)
|
|
86
|
+
add_video_campaign()
|
|
86
87
|
|
|
87
88
|
# HTTP errors.
|
|
88
89
|
rescue AdsCommon::Errors::HttpError => e
|
data/examples/{v201206/basic_operations/pause_ad.rb → v201209/adwords_for_video/find_videos.rb}
RENAMED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
|
5
5
|
#
|
|
6
|
-
# Copyright:: Copyright
|
|
6
|
+
# Copyright:: Copyright 2013, Google Inc. All Rights Reserved.
|
|
7
7
|
#
|
|
8
8
|
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
9
|
# you may not use this file except in compliance with the License.
|
|
@@ -18,14 +18,16 @@
|
|
|
18
18
|
# See the License for the specific language governing permissions and
|
|
19
19
|
# limitations under the License.
|
|
20
20
|
#
|
|
21
|
-
# This example illustrates how to
|
|
22
|
-
#
|
|
21
|
+
# This example illustrates how to find YouTube videos by a search string. It
|
|
22
|
+
# retrieve details for the first 100 matching videos.
|
|
23
23
|
#
|
|
24
|
-
#
|
|
24
|
+
# Note: AdWords for Video API is a Beta feature.
|
|
25
|
+
#
|
|
26
|
+
# Tags: VideoService.search
|
|
25
27
|
|
|
26
28
|
require 'adwords_api'
|
|
27
29
|
|
|
28
|
-
def
|
|
30
|
+
def find_videos()
|
|
29
31
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
30
32
|
# when called without parameters.
|
|
31
33
|
adwords = AdwordsApi::Api.new
|
|
@@ -34,37 +36,43 @@ def pause_ad(ad_group_id, ad_id)
|
|
|
34
36
|
# the configuration file or provide your own logger:
|
|
35
37
|
# adwords.logger = Logger.new('adwords_xml.log')
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
video_srv = adwords.service(:VideoService, API_VERSION)
|
|
40
|
+
|
|
41
|
+
# Search string to use.
|
|
42
|
+
query_str = 'AdWords API with Ruby'
|
|
38
43
|
|
|
39
|
-
#
|
|
40
|
-
|
|
41
|
-
:
|
|
42
|
-
:
|
|
43
|
-
|
|
44
|
-
:
|
|
45
|
-
:
|
|
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
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
|
|
49
|
-
#
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
55
65
|
else
|
|
56
|
-
puts
|
|
66
|
+
puts "No videos matching '%s' were found." % query_str
|
|
57
67
|
end
|
|
58
68
|
end
|
|
59
69
|
|
|
60
70
|
if __FILE__ == $0
|
|
61
|
-
API_VERSION = :
|
|
71
|
+
API_VERSION = :v201209
|
|
72
|
+
PAGE_SIZE = 100
|
|
62
73
|
|
|
63
74
|
begin
|
|
64
|
-
|
|
65
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
|
66
|
-
ad_id = 'INSERT_AD_ID_HERE'.to_i
|
|
67
|
-
pause_ad(ad_group_id, ad_id)
|
|
75
|
+
find_videos()
|
|
68
76
|
|
|
69
77
|
# HTTP errors.
|
|
70
78
|
rescue AdsCommon::Errors::HttpError => e
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
|
5
5
|
#
|
|
6
|
-
# Copyright:: Copyright
|
|
6
|
+
# Copyright:: Copyright 2013, Google Inc. All Rights Reserved.
|
|
7
7
|
#
|
|
8
8
|
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
9
|
# you may not use this file except in compliance with the License.
|
|
@@ -18,14 +18,16 @@
|
|
|
18
18
|
# See the License for the specific language governing permissions and
|
|
19
19
|
# limitations under the License.
|
|
20
20
|
#
|
|
21
|
-
# This example
|
|
22
|
-
#
|
|
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
23
|
#
|
|
24
|
-
#
|
|
24
|
+
# Note: AdWords for Video API is a Beta feature.
|
|
25
|
+
#
|
|
26
|
+
# Tags: VideoTargetingGroupCriterionService.get
|
|
25
27
|
|
|
26
28
|
require 'adwords_api'
|
|
27
29
|
|
|
28
|
-
def
|
|
30
|
+
def get_keyword_criteria(campaign_id)
|
|
29
31
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
30
32
|
# when called without parameters.
|
|
31
33
|
adwords = AdwordsApi::Api.new
|
|
@@ -34,19 +36,13 @@ def get_keywords(ad_group_id)
|
|
|
34
36
|
# the configuration file or provide your own logger:
|
|
35
37
|
# adwords.logger = Logger.new('adwords_xml.log')
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
adwords.service(:
|
|
39
|
+
vtgc_srv =
|
|
40
|
+
adwords.service(:VideoTargetingGroupCriterionService, API_VERSION)
|
|
39
41
|
|
|
40
|
-
# Get all keywords for
|
|
42
|
+
# Get all the keywords for the campaign.
|
|
41
43
|
selector = {
|
|
42
|
-
:
|
|
43
|
-
:
|
|
44
|
-
{:field => 'Id', :sort_order => 'ASCENDING'}
|
|
45
|
-
],
|
|
46
|
-
:predicates => [
|
|
47
|
-
{:field => 'AdGroupId', :operator => 'EQUALS', :values => [ad_group_id]},
|
|
48
|
-
{:field => 'CriteriaType', :operator => 'EQUALS', :values => ['KEYWORD']}
|
|
49
|
-
],
|
|
44
|
+
:campaign_ids => [campaign_id],
|
|
45
|
+
:criterion_types => ['SEARCH_KEYWORD'],
|
|
50
46
|
:paging => {
|
|
51
47
|
:start_index => 0,
|
|
52
48
|
:number_results => PAGE_SIZE
|
|
@@ -57,13 +53,15 @@ def get_keywords(ad_group_id)
|
|
|
57
53
|
offset, page = 0, {}
|
|
58
54
|
|
|
59
55
|
begin
|
|
60
|
-
page =
|
|
56
|
+
page = vtgc_srv.get(selector)
|
|
61
57
|
if page[:entries]
|
|
62
58
|
page[:entries].each do |keyword|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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]]
|
|
67
65
|
end
|
|
68
66
|
# Increment values to request the next page.
|
|
69
67
|
offset += PAGE_SIZE
|
|
@@ -72,19 +70,18 @@ def get_keywords(ad_group_id)
|
|
|
72
70
|
end while page[:total_num_entries] > offset
|
|
73
71
|
|
|
74
72
|
if page.include?(:total_num_entries)
|
|
75
|
-
puts "\
|
|
76
|
-
[ad_group_id, page[:total_num_entries]]
|
|
73
|
+
puts "\tTotal number of keywords found: %d." % [page[:total_num_entries]]
|
|
77
74
|
end
|
|
78
75
|
end
|
|
79
76
|
|
|
80
77
|
if __FILE__ == $0
|
|
81
|
-
API_VERSION = :
|
|
78
|
+
API_VERSION = :v201209
|
|
82
79
|
PAGE_SIZE = 500
|
|
83
80
|
|
|
84
81
|
begin
|
|
85
|
-
#
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
# Campaign ID to get criteria for.
|
|
83
|
+
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
|
84
|
+
get_keyword_criteria(campaign_id)
|
|
88
85
|
|
|
89
86
|
# HTTP errors.
|
|
90
87
|
rescue AdsCommon::Errors::HttpError => e
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
|
5
5
|
#
|
|
6
|
-
# Copyright:: Copyright
|
|
6
|
+
# Copyright:: Copyright 2013, Google Inc. All Rights Reserved.
|
|
7
7
|
#
|
|
8
8
|
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
9
|
# you may not use this file except in compliance with the License.
|
|
@@ -18,14 +18,15 @@
|
|
|
18
18
|
# See the License for the specific language governing permissions and
|
|
19
19
|
# limitations under the License.
|
|
20
20
|
#
|
|
21
|
-
# This example
|
|
22
|
-
# AWQL.
|
|
21
|
+
# This example show how to retrieve all targeting groups for an account.
|
|
23
22
|
#
|
|
24
|
-
#
|
|
23
|
+
# Note: AdWords for Video API is a Beta feature.
|
|
24
|
+
#
|
|
25
|
+
# Tags: VideoTargetingGroupService.get
|
|
25
26
|
|
|
26
27
|
require 'adwords_api'
|
|
27
28
|
|
|
28
|
-
def
|
|
29
|
+
def get_targeting_groups()
|
|
29
30
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
30
31
|
# when called without parameters.
|
|
31
32
|
adwords = AdwordsApi::Api.new
|
|
@@ -34,46 +35,53 @@ def get_campaigns_with_awql()
|
|
|
34
35
|
# the configuration file or provide your own logger:
|
|
35
36
|
# adwords.logger = Logger.new('adwords_xml.log')
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
video_targeting_group_srv =
|
|
39
|
+
adwords.service(:VideoTargetingGroupService, API_VERSION)
|
|
38
40
|
|
|
39
|
-
# Get all
|
|
40
|
-
|
|
41
|
+
# Get all targeting groups for this account.
|
|
42
|
+
selector = {
|
|
43
|
+
:paging => {
|
|
44
|
+
:start_index => 0,
|
|
45
|
+
:number_results => PAGE_SIZE
|
|
46
|
+
}
|
|
47
|
+
}
|
|
41
48
|
|
|
42
49
|
# Set initial values.
|
|
43
50
|
offset, page = 0, {}
|
|
44
51
|
|
|
45
52
|
begin
|
|
46
|
-
|
|
47
|
-
page = campaign_srv.query(page_query)
|
|
53
|
+
page = video_targeting_group_srv.get(selector)
|
|
48
54
|
if page[:entries]
|
|
49
|
-
page[:entries].each do |
|
|
50
|
-
puts "
|
|
51
|
-
[
|
|
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]]
|
|
52
58
|
end
|
|
53
59
|
# Increment values to request the next page.
|
|
54
60
|
offset += PAGE_SIZE
|
|
61
|
+
selector[:paging][:start_index] = offset
|
|
55
62
|
end
|
|
56
63
|
end while page[:total_num_entries] > offset
|
|
57
64
|
|
|
58
65
|
if page.include?(:total_num_entries)
|
|
59
|
-
puts "\tTotal number of
|
|
66
|
+
puts "\tTotal number of targeting groups found: %d." %
|
|
67
|
+
[page[:total_num_entries]]
|
|
60
68
|
end
|
|
61
69
|
end
|
|
62
70
|
|
|
63
71
|
if __FILE__ == $0
|
|
64
|
-
API_VERSION = :
|
|
72
|
+
API_VERSION = :v201209
|
|
65
73
|
PAGE_SIZE = 500
|
|
66
74
|
|
|
67
75
|
begin
|
|
68
|
-
|
|
76
|
+
get_targeting_groups()
|
|
69
77
|
|
|
70
78
|
# HTTP errors.
|
|
71
79
|
rescue AdsCommon::Errors::HttpError => e
|
|
72
|
-
puts
|
|
80
|
+
puts "HTTP Error: %s" % e
|
|
73
81
|
|
|
74
82
|
# API errors.
|
|
75
83
|
rescue AdwordsApi::Errors::ApiException => e
|
|
76
|
-
puts
|
|
84
|
+
puts "Message: %s" % e.message
|
|
77
85
|
puts 'Errors:'
|
|
78
86
|
e.errors.each_with_index do |error, index|
|
|
79
87
|
puts "\tError [%d]:" % (index + 1)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
|
5
5
|
#
|
|
6
|
-
# Copyright:: Copyright
|
|
6
|
+
# Copyright:: Copyright 2013, Google Inc. All Rights Reserved.
|
|
7
7
|
#
|
|
8
8
|
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
9
|
# you may not use this file except in compliance with the License.
|
|
@@ -18,14 +18,15 @@
|
|
|
18
18
|
# See the License for the specific language governing permissions and
|
|
19
19
|
# limitations under the License.
|
|
20
20
|
#
|
|
21
|
-
# This example
|
|
22
|
-
# create an ad group, run add_ad_group.rb.
|
|
21
|
+
# This example demonstrates how to retrieve all campaign-level criteria.
|
|
23
22
|
#
|
|
24
|
-
#
|
|
23
|
+
# Note: AdWords for Video API is a Beta feature.
|
|
24
|
+
#
|
|
25
|
+
# Tags: VideoCampaignCriterionService.get
|
|
25
26
|
|
|
26
27
|
require 'adwords_api'
|
|
27
28
|
|
|
28
|
-
def
|
|
29
|
+
def get_video_campaign_criteria(campaign_id)
|
|
29
30
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
30
31
|
# when called without parameters.
|
|
31
32
|
adwords = AdwordsApi::Api.new
|
|
@@ -34,15 +35,12 @@ def get_ad_groups(campaign_id)
|
|
|
34
35
|
# the configuration file or provide your own logger:
|
|
35
36
|
# adwords.logger = Logger.new('adwords_xml.log')
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
vtgc_srv =
|
|
39
|
+
adwords.service(:VideoCampaignCriterionService, API_VERSION)
|
|
38
40
|
|
|
39
|
-
# Get all
|
|
41
|
+
# Get all criteria for the campaign.
|
|
40
42
|
selector = {
|
|
41
|
-
:
|
|
42
|
-
:ordering => [{:field => 'Name', :sort_order => 'ASCENDING'}],
|
|
43
|
-
:predicates => [
|
|
44
|
-
{:field => 'CampaignId', :operator => 'IN', :values => [campaign_id]}
|
|
45
|
-
],
|
|
43
|
+
:campaign_ids => [campaign_id],
|
|
46
44
|
:paging => {
|
|
47
45
|
:start_index => 0,
|
|
48
46
|
:number_results => PAGE_SIZE
|
|
@@ -53,11 +51,14 @@ def get_ad_groups(campaign_id)
|
|
|
53
51
|
offset, page = 0, {}
|
|
54
52
|
|
|
55
53
|
begin
|
|
56
|
-
page =
|
|
54
|
+
page = vtgc_srv.get(selector)
|
|
57
55
|
if page[:entries]
|
|
58
|
-
page[:entries].each do |
|
|
59
|
-
|
|
60
|
-
[
|
|
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]]
|
|
61
62
|
end
|
|
62
63
|
# Increment values to request the next page.
|
|
63
64
|
offset += PAGE_SIZE
|
|
@@ -66,19 +67,19 @@ def get_ad_groups(campaign_id)
|
|
|
66
67
|
end while page[:total_num_entries] > offset
|
|
67
68
|
|
|
68
69
|
if page.include?(:total_num_entries)
|
|
69
|
-
puts "\
|
|
70
|
-
[campaign_id, page[:total_num_entries]]
|
|
70
|
+
puts "\tTotal number of criteria found: %d." % [page[:total_num_entries]]
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
if __FILE__ == $0
|
|
75
|
-
API_VERSION = :
|
|
75
|
+
API_VERSION = :v201209
|
|
76
76
|
PAGE_SIZE = 500
|
|
77
77
|
|
|
78
78
|
begin
|
|
79
|
-
# Campaign ID to get
|
|
79
|
+
# Campaign ID to get criteria for.
|
|
80
80
|
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
|
81
|
-
|
|
81
|
+
|
|
82
|
+
get_video_campaign_criteria(campaign_id)
|
|
82
83
|
|
|
83
84
|
# HTTP errors.
|
|
84
85
|
rescue AdsCommon::Errors::HttpError => e
|