google-adwords-api 0.6.3 → 0.7.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 +4 -0
- data/examples/v201109/misc/get_all_images_and_videos.rb +3 -4
- data/examples/v201109/misc/upload_image.rb +6 -7
- data/examples/v201109/optimization/get_keyword_ideas.rb +1 -2
- data/examples/v201109/optimization/get_placement_ideas.rb +1 -3
- data/examples/v201109_1/misc/get_all_images_and_videos.rb +3 -4
- data/examples/v201109_1/misc/upload_image.rb +6 -7
- data/examples/v201109_1/optimization/get_keyword_ideas.rb +1 -2
- data/examples/v201109_1/optimization/get_placement_ideas.rb +1 -3
- data/examples/v201206/misc/get_all_images_and_videos.rb +3 -4
- data/examples/v201206/misc/upload_image.rb +6 -7
- data/examples/v201206/optimization/get_keyword_ideas.rb +1 -2
- data/examples/v201206/optimization/get_placement_ideas.rb +1 -3
- data/examples/v201206/reporting/parallel_report_download.rb +12 -12
- data/lib/adwords_api.rb +9 -13
- data/lib/adwords_api/api_config.rb +2 -3
- data/lib/adwords_api/client_login_header_handler.rb +0 -47
- data/lib/adwords_api/credential_handler.rb +5 -17
- data/lib/adwords_api/errors.rb +7 -2
- data/lib/adwords_api/report_header_handler.rb +1 -1
- data/lib/adwords_api/utils.rb +0 -16
- data/lib/adwords_api/v201109/ad_extension_override_service.rb +1 -1
- data/lib/adwords_api/v201109/ad_extension_override_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/ad_group_ad_service.rb +1 -1
- data/lib/adwords_api/v201109/ad_group_ad_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/ad_group_criterion_service.rb +1 -1
- data/lib/adwords_api/v201109/ad_group_criterion_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/ad_group_service.rb +1 -1
- data/lib/adwords_api/v201109/ad_group_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/ad_param_service.rb +1 -1
- data/lib/adwords_api/v201109/ad_param_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/alert_service.rb +1 -1
- data/lib/adwords_api/v201109/alert_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/budget_order_service.rb +1 -1
- data/lib/adwords_api/v201109/budget_order_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/bulk_mutate_job_service.rb +1 -1
- data/lib/adwords_api/v201109/bulk_mutate_job_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/campaign_ad_extension_service.rb +1 -1
- data/lib/adwords_api/v201109/campaign_ad_extension_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/campaign_criterion_service.rb +1 -1
- data/lib/adwords_api/v201109/campaign_criterion_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/campaign_service.rb +1 -1
- data/lib/adwords_api/v201109/campaign_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/campaign_target_service.rb +1 -1
- data/lib/adwords_api/v201109/campaign_target_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/constant_data_service.rb +1 -1
- data/lib/adwords_api/v201109/constant_data_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/conversion_tracker_service.rb +1 -1
- data/lib/adwords_api/v201109/conversion_tracker_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/create_account_service.rb +1 -1
- data/lib/adwords_api/v201109/create_account_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/customer_sync_service.rb +1 -1
- data/lib/adwords_api/v201109/customer_sync_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/data_service.rb +1 -1
- data/lib/adwords_api/v201109/data_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/experiment_service.rb +1 -1
- data/lib/adwords_api/v201109/experiment_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/geo_location_service.rb +1 -1
- data/lib/adwords_api/v201109/geo_location_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/info_service.rb +1 -1
- data/lib/adwords_api/v201109/info_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/location_criterion_service.rb +1 -1
- data/lib/adwords_api/v201109/location_criterion_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/media_service.rb +1 -1
- data/lib/adwords_api/v201109/media_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/mutate_job_service.rb +1 -1
- data/lib/adwords_api/v201109/mutate_job_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/report_definition_service.rb +1 -1
- data/lib/adwords_api/v201109/report_definition_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/serviced_account_service.rb +1 -1
- data/lib/adwords_api/v201109/serviced_account_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/targeting_idea_service.rb +1 -1
- data/lib/adwords_api/v201109/targeting_idea_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/traffic_estimator_service.rb +1 -1
- data/lib/adwords_api/v201109/traffic_estimator_service_registry.rb +3 -3
- data/lib/adwords_api/v201109/user_list_service.rb +1 -1
- data/lib/adwords_api/v201109/user_list_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/ad_extension_override_service.rb +1 -1
- data/lib/adwords_api/v201109_1/ad_extension_override_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/ad_group_ad_service.rb +1 -1
- data/lib/adwords_api/v201109_1/ad_group_ad_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/ad_group_criterion_service.rb +1 -1
- data/lib/adwords_api/v201109_1/ad_group_criterion_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/ad_group_service.rb +1 -1
- data/lib/adwords_api/v201109_1/ad_group_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/ad_param_service.rb +1 -1
- data/lib/adwords_api/v201109_1/ad_param_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/alert_service.rb +1 -1
- data/lib/adwords_api/v201109_1/alert_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/budget_order_service.rb +1 -1
- data/lib/adwords_api/v201109_1/budget_order_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/bulk_mutate_job_service.rb +1 -1
- data/lib/adwords_api/v201109_1/bulk_mutate_job_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/campaign_ad_extension_service.rb +1 -1
- data/lib/adwords_api/v201109_1/campaign_ad_extension_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/campaign_criterion_service.rb +1 -1
- data/lib/adwords_api/v201109_1/campaign_criterion_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/campaign_service.rb +1 -1
- data/lib/adwords_api/v201109_1/campaign_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/campaign_target_service.rb +1 -1
- data/lib/adwords_api/v201109_1/campaign_target_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/constant_data_service.rb +1 -1
- data/lib/adwords_api/v201109_1/constant_data_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/conversion_tracker_service.rb +1 -1
- data/lib/adwords_api/v201109_1/conversion_tracker_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/create_account_service.rb +1 -1
- data/lib/adwords_api/v201109_1/create_account_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/customer_service.rb +1 -1
- data/lib/adwords_api/v201109_1/customer_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/customer_sync_service.rb +1 -1
- data/lib/adwords_api/v201109_1/customer_sync_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/data_service.rb +1 -1
- data/lib/adwords_api/v201109_1/data_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/experiment_service.rb +1 -1
- data/lib/adwords_api/v201109_1/experiment_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/geo_location_service.rb +1 -1
- data/lib/adwords_api/v201109_1/geo_location_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/info_service.rb +1 -1
- data/lib/adwords_api/v201109_1/info_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/location_criterion_service.rb +1 -1
- data/lib/adwords_api/v201109_1/location_criterion_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/managed_customer_service.rb +1 -1
- data/lib/adwords_api/v201109_1/managed_customer_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/media_service.rb +1 -1
- data/lib/adwords_api/v201109_1/media_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/mutate_job_service.rb +1 -1
- data/lib/adwords_api/v201109_1/mutate_job_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/report_definition_service.rb +1 -1
- data/lib/adwords_api/v201109_1/report_definition_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/serviced_account_service.rb +1 -1
- data/lib/adwords_api/v201109_1/serviced_account_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/targeting_idea_service.rb +1 -1
- data/lib/adwords_api/v201109_1/targeting_idea_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/traffic_estimator_service.rb +1 -1
- data/lib/adwords_api/v201109_1/traffic_estimator_service_registry.rb +3 -3
- data/lib/adwords_api/v201109_1/user_list_service.rb +1 -1
- data/lib/adwords_api/v201109_1/user_list_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/ad_extension_override_service.rb +1 -1
- data/lib/adwords_api/v201206/ad_extension_override_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/ad_group_ad_service.rb +1 -1
- data/lib/adwords_api/v201206/ad_group_ad_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/ad_group_criterion_service.rb +1 -1
- data/lib/adwords_api/v201206/ad_group_criterion_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/ad_group_service.rb +1 -1
- data/lib/adwords_api/v201206/ad_group_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/ad_param_service.rb +1 -1
- data/lib/adwords_api/v201206/ad_param_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/alert_service.rb +1 -1
- data/lib/adwords_api/v201206/alert_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/budget_order_service.rb +1 -1
- data/lib/adwords_api/v201206/budget_order_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/bulk_mutate_job_service.rb +1 -1
- data/lib/adwords_api/v201206/bulk_mutate_job_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/campaign_ad_extension_service.rb +1 -1
- data/lib/adwords_api/v201206/campaign_ad_extension_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/campaign_criterion_service.rb +1 -1
- data/lib/adwords_api/v201206/campaign_criterion_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/campaign_service.rb +1 -1
- data/lib/adwords_api/v201206/campaign_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/constant_data_service.rb +1 -1
- data/lib/adwords_api/v201206/constant_data_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/conversion_tracker_service.rb +1 -1
- data/lib/adwords_api/v201206/conversion_tracker_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/customer_service.rb +1 -1
- data/lib/adwords_api/v201206/customer_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/customer_sync_service.rb +1 -1
- data/lib/adwords_api/v201206/customer_sync_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/data_service.rb +1 -1
- data/lib/adwords_api/v201206/data_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/experiment_service.rb +1 -1
- data/lib/adwords_api/v201206/experiment_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/geo_location_service.rb +1 -1
- data/lib/adwords_api/v201206/geo_location_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/info_service.rb +1 -1
- data/lib/adwords_api/v201206/info_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/location_criterion_service.rb +1 -1
- data/lib/adwords_api/v201206/location_criterion_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/managed_customer_service.rb +1 -1
- data/lib/adwords_api/v201206/managed_customer_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/media_service.rb +1 -1
- data/lib/adwords_api/v201206/media_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/mutate_job_service.rb +1 -1
- data/lib/adwords_api/v201206/mutate_job_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/report_definition_service.rb +1 -1
- data/lib/adwords_api/v201206/report_definition_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/targeting_idea_service.rb +1 -1
- data/lib/adwords_api/v201206/targeting_idea_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/traffic_estimator_service.rb +1 -1
- data/lib/adwords_api/v201206/traffic_estimator_service_registry.rb +3 -3
- data/lib/adwords_api/v201206/user_list_service.rb +1 -1
- data/lib/adwords_api/v201206/user_list_service_registry.rb +3 -3
- data/lib/adwords_api/version.rb +1 -1
- data/test/adwords_api/test_utils.rb +0 -13
- data/test/examples/v201109/test_reporting.rb +0 -5
- data/test/examples/v201109/utils.rb +1 -2
- data/test/examples/v201109_1/test_reporting.rb +0 -5
- data/test/examples/v201109_1/utils.rb +1 -2
- data/test/examples/v201206/test_reporting.rb +0 -5
- data/test/examples/v201206/utils.rb +1 -2
- metadata +4 -5
- data/examples/v201206/reporting/get_defined_reports.rb +0 -75
data/ChangeLog
CHANGED
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
# Tags: MediaService.get
|
|
26
26
|
|
|
27
27
|
require 'adwords_api'
|
|
28
|
-
require 'adwords_api/utils'
|
|
29
28
|
|
|
30
29
|
def get_all_images_and_videos()
|
|
31
30
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
@@ -60,10 +59,10 @@ def get_all_images_and_videos()
|
|
|
60
59
|
page = media_srv.get(selector)
|
|
61
60
|
if page[:entries]
|
|
62
61
|
page[:entries].each do |entry|
|
|
63
|
-
|
|
62
|
+
full_dimensions = entry[:dimensions]['FULL']
|
|
64
63
|
puts "Entry ID %d with dimensions %dx%d and MIME type is '%s'" %
|
|
65
|
-
[entry[:media_id],
|
|
66
|
-
|
|
64
|
+
[entry[:media_id], full_dimensions[:height],
|
|
65
|
+
full_dimensions[:width], entry[:mime_type]]
|
|
67
66
|
end
|
|
68
67
|
# Increment values to request the next page.
|
|
69
68
|
offset += PAGE_SIZE
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# Encoding: utf-8
|
|
3
3
|
#
|
|
4
|
-
# Author:: api.
|
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
|
5
5
|
#
|
|
6
6
|
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
|
7
7
|
#
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
# Tags: MediaService.upload
|
|
24
24
|
|
|
25
25
|
require 'adwords_api'
|
|
26
|
-
require 'adwords_api/utils'
|
|
27
26
|
require 'base64'
|
|
28
27
|
|
|
29
28
|
def upload_image()
|
|
@@ -57,12 +56,12 @@ def upload_image()
|
|
|
57
56
|
response = media_srv.upload([image])
|
|
58
57
|
if response and !response.empty?
|
|
59
58
|
ret_image = response.first
|
|
60
|
-
|
|
61
|
-
puts "Image with
|
|
62
|
-
"
|
|
63
|
-
|
|
59
|
+
full_dimensions = ret_image[:dimensions]['FULL']
|
|
60
|
+
puts ("Image with ID %d, dimensions %dx%d and MIME type '%s' uploaded " +
|
|
61
|
+
"successfully.") % [ret_image[:media_id], full_dimensions[:height],
|
|
62
|
+
full_dimensions[:width], ret_image[:mime_type]]
|
|
64
63
|
else
|
|
65
|
-
puts
|
|
64
|
+
puts 'No images uploaded.'
|
|
66
65
|
end
|
|
67
66
|
end
|
|
68
67
|
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
# Tags: TargetingIdeaService.get
|
|
24
24
|
|
|
25
25
|
require 'adwords_api'
|
|
26
|
-
require 'adwords_api/utils'
|
|
27
26
|
|
|
28
27
|
def get_keyword_ideas(keyword_text)
|
|
29
28
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
@@ -73,7 +72,7 @@ def get_keyword_ideas(keyword_text)
|
|
|
73
72
|
|
|
74
73
|
# Display results.
|
|
75
74
|
results.each do |result|
|
|
76
|
-
data =
|
|
75
|
+
data = result[:data]
|
|
77
76
|
keyword = data['CRITERION'][:value]
|
|
78
77
|
puts "Found keyword with text '%s' and match type '%s'" %
|
|
79
78
|
[keyword[:text], keyword[:match_type]]
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
# Tags: TargetingIdeaService.get
|
|
25
25
|
|
|
26
26
|
require 'adwords_api'
|
|
27
|
-
require 'adwords_api/utils'
|
|
28
27
|
|
|
29
28
|
def get_placement_ideas(url)
|
|
30
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
@@ -72,8 +71,7 @@ def get_placement_ideas(url)
|
|
|
72
71
|
|
|
73
72
|
# Display results.
|
|
74
73
|
results.each do |result|
|
|
75
|
-
|
|
76
|
-
placement = data['CRITERION'][:value]
|
|
74
|
+
placement = result[:data]['CRITERION'][:value]
|
|
77
75
|
puts "Related placement found at URL [%s]" % placement[:url]
|
|
78
76
|
end
|
|
79
77
|
puts "Total URLs found with keywords related to keywords at [%s]: %d." %
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
# Tags: MediaService.get
|
|
26
26
|
|
|
27
27
|
require 'adwords_api'
|
|
28
|
-
require 'adwords_api/utils'
|
|
29
28
|
|
|
30
29
|
def get_all_images_and_videos()
|
|
31
30
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
@@ -60,10 +59,10 @@ def get_all_images_and_videos()
|
|
|
60
59
|
page = media_srv.get(selector)
|
|
61
60
|
if page[:entries]
|
|
62
61
|
page[:entries].each do |entry|
|
|
63
|
-
|
|
62
|
+
full_dimensions = entry[:dimensions]['FULL']
|
|
64
63
|
puts "Entry ID %d with dimensions %dx%d and MIME type is '%s'" %
|
|
65
|
-
[entry[:media_id],
|
|
66
|
-
|
|
64
|
+
[entry[:media_id], full_dimensions[:height],
|
|
65
|
+
full_dimensions[:width], entry[:mime_type]]
|
|
67
66
|
end
|
|
68
67
|
# Increment values to request the next page.
|
|
69
68
|
offset += PAGE_SIZE
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# Encoding: utf-8
|
|
3
3
|
#
|
|
4
|
-
# Author:: api.
|
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
|
5
5
|
#
|
|
6
6
|
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
|
7
7
|
#
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
# Tags: MediaService.upload
|
|
24
24
|
|
|
25
25
|
require 'adwords_api'
|
|
26
|
-
require 'adwords_api/utils'
|
|
27
26
|
require 'base64'
|
|
28
27
|
|
|
29
28
|
def upload_image()
|
|
@@ -57,12 +56,12 @@ def upload_image()
|
|
|
57
56
|
response = media_srv.upload([image])
|
|
58
57
|
if response and !response.empty?
|
|
59
58
|
ret_image = response.first
|
|
60
|
-
|
|
61
|
-
puts "Image with
|
|
62
|
-
"
|
|
63
|
-
|
|
59
|
+
full_dimensions = ret_image[:dimensions]['FULL']
|
|
60
|
+
puts ("Image with ID %d, dimensions %dx%d and MIME type '%s' uploaded " +
|
|
61
|
+
"successfully.") % [ret_image[:media_id], full_dimensions[:height],
|
|
62
|
+
full_dimensions[:width], ret_image[:mime_type]]
|
|
64
63
|
else
|
|
65
|
-
puts
|
|
64
|
+
puts 'No images uploaded.'
|
|
66
65
|
end
|
|
67
66
|
end
|
|
68
67
|
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
# Tags: TargetingIdeaService.get
|
|
24
24
|
|
|
25
25
|
require 'adwords_api'
|
|
26
|
-
require 'adwords_api/utils'
|
|
27
26
|
|
|
28
27
|
def get_keyword_ideas(keyword_text)
|
|
29
28
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
@@ -74,7 +73,7 @@ def get_keyword_ideas(keyword_text)
|
|
|
74
73
|
|
|
75
74
|
# Display results.
|
|
76
75
|
results.each do |result|
|
|
77
|
-
data =
|
|
76
|
+
data = result[:data]
|
|
78
77
|
keyword = data['CRITERION'][:value]
|
|
79
78
|
puts "Found keyword with text '%s' and match type '%s'" %
|
|
80
79
|
[keyword[:text], keyword[:match_type]]
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
# Tags: TargetingIdeaService.get
|
|
25
25
|
|
|
26
26
|
require 'adwords_api'
|
|
27
|
-
require 'adwords_api/utils'
|
|
28
27
|
|
|
29
28
|
def get_placement_ideas(url)
|
|
30
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
@@ -72,8 +71,7 @@ def get_placement_ideas(url)
|
|
|
72
71
|
|
|
73
72
|
# Display results.
|
|
74
73
|
results.each do |result|
|
|
75
|
-
|
|
76
|
-
placement = data['CRITERION'][:value]
|
|
74
|
+
placement = result[:data]['CRITERION'][:value]
|
|
77
75
|
puts "Related placement found at URL [%s]" % placement[:url]
|
|
78
76
|
end
|
|
79
77
|
puts "Total URLs found with keywords related to keywords at [%s]: %d." %
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
# Tags: MediaService.get
|
|
26
26
|
|
|
27
27
|
require 'adwords_api'
|
|
28
|
-
require 'adwords_api/utils'
|
|
29
28
|
|
|
30
29
|
def get_all_images_and_videos()
|
|
31
30
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
@@ -60,10 +59,10 @@ def get_all_images_and_videos()
|
|
|
60
59
|
page = media_srv.get(selector)
|
|
61
60
|
if page[:entries]
|
|
62
61
|
page[:entries].each do |entry|
|
|
63
|
-
|
|
62
|
+
full_dimensions = entry[:dimensions]['FULL']
|
|
64
63
|
puts "Entry ID %d with dimensions %dx%d and MIME type is '%s'" %
|
|
65
|
-
[entry[:media_id],
|
|
66
|
-
|
|
64
|
+
[entry[:media_id], full_dimensions[:height],
|
|
65
|
+
full_dimensions[:width], entry[:mime_type]]
|
|
67
66
|
end
|
|
68
67
|
# Increment values to request the next page.
|
|
69
68
|
offset += PAGE_SIZE
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# Encoding: utf-8
|
|
3
3
|
#
|
|
4
|
-
# Author:: api.
|
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
|
5
5
|
#
|
|
6
6
|
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
|
7
7
|
#
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
# Tags: MediaService.upload
|
|
24
24
|
|
|
25
25
|
require 'adwords_api'
|
|
26
|
-
require 'adwords_api/utils'
|
|
27
26
|
require 'base64'
|
|
28
27
|
|
|
29
28
|
def upload_image()
|
|
@@ -57,12 +56,12 @@ def upload_image()
|
|
|
57
56
|
response = media_srv.upload([image])
|
|
58
57
|
if response and !response.empty?
|
|
59
58
|
ret_image = response.first
|
|
60
|
-
|
|
61
|
-
puts "Image with
|
|
62
|
-
"
|
|
63
|
-
|
|
59
|
+
full_dimensions = ret_image[:dimensions]['FULL']
|
|
60
|
+
puts ("Image with ID %d, dimensions %dx%d and MIME type '%s' uploaded " +
|
|
61
|
+
"successfully.") % [ret_image[:media_id], full_dimensions[:height],
|
|
62
|
+
full_dimensions[:width], ret_image[:mime_type]]
|
|
64
63
|
else
|
|
65
|
-
puts
|
|
64
|
+
puts 'No images uploaded.'
|
|
66
65
|
end
|
|
67
66
|
end
|
|
68
67
|
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
# Tags: TargetingIdeaService.get
|
|
24
24
|
|
|
25
25
|
require 'adwords_api'
|
|
26
|
-
require 'adwords_api/utils'
|
|
27
26
|
|
|
28
27
|
def get_keyword_ideas(keyword_text)
|
|
29
28
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
@@ -73,7 +72,7 @@ def get_keyword_ideas(keyword_text)
|
|
|
73
72
|
|
|
74
73
|
# Display results.
|
|
75
74
|
results.each do |result|
|
|
76
|
-
data =
|
|
75
|
+
data = result[:data]
|
|
77
76
|
keyword = data['KEYWORD_TEXT'][:value]
|
|
78
77
|
puts "Found keyword with text '%s'" % keyword
|
|
79
78
|
products_and_services = data['CATEGORY_PRODUCTS_AND_SERVICES'][:value]
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
# Tags: TargetingIdeaService.get
|
|
25
25
|
|
|
26
26
|
require 'adwords_api'
|
|
27
|
-
require 'adwords_api/utils'
|
|
28
27
|
|
|
29
28
|
def get_placement_ideas(url)
|
|
30
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
@@ -72,8 +71,7 @@ def get_placement_ideas(url)
|
|
|
72
71
|
|
|
73
72
|
# Display results.
|
|
74
73
|
results.each do |result|
|
|
75
|
-
|
|
76
|
-
placement = data['CRITERION'][:value]
|
|
74
|
+
placement = result[:data]['CRITERION'][:value]
|
|
77
75
|
puts "Related placement found at URL [%s]" % placement[:url]
|
|
78
76
|
end
|
|
79
77
|
puts "Total URLs found with keywords related to keywords at [%s]: %d." %
|
|
@@ -35,21 +35,21 @@ def parallel_report_download()
|
|
|
35
35
|
# adwords.logger = Logger.new('adwords_xml.log')
|
|
36
36
|
|
|
37
37
|
# Determine list of customer IDs to retrieve report for. For this example we
|
|
38
|
-
# will use
|
|
38
|
+
# will use ManagedCustomerService to get all IDs in hierarchy.
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
managed_customer_srv = adwords.service(:ManagedCustomerService, API_VERSION)
|
|
41
41
|
|
|
42
42
|
# Get the account hierarchy for this account.
|
|
43
|
-
selector = {:
|
|
43
|
+
selector = {:fields => ['CustomerId']}
|
|
44
44
|
|
|
45
45
|
# Run the request at the MCC level.
|
|
46
|
-
graph = adwords.use_mcc() {
|
|
46
|
+
graph = adwords.use_mcc() {managed_customer_srv.get(selector)}
|
|
47
47
|
|
|
48
48
|
# Using queue to balance load between threads.
|
|
49
49
|
queue = Queue.new()
|
|
50
50
|
|
|
51
|
-
if graph and graph[:
|
|
52
|
-
graph[:
|
|
51
|
+
if graph and graph[:entries] and !graph[:entries].empty?
|
|
52
|
+
graph[:entries].each {|account| queue << account[:customer_id]}
|
|
53
53
|
else
|
|
54
54
|
raise StandardError, 'Can not retrieve any customer ID'
|
|
55
55
|
end
|
|
@@ -76,7 +76,7 @@ def parallel_report_download()
|
|
|
76
76
|
:include_zero_impressions => false
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
puts
|
|
79
|
+
puts 'Retrieving %d reports with %d threads:' % [queue.size, THREADS]
|
|
80
80
|
|
|
81
81
|
reports_succeeded = Queue.new()
|
|
82
82
|
reports_failed = Queue.new()
|
|
@@ -92,7 +92,7 @@ def parallel_report_download()
|
|
|
92
92
|
cid = queue_mutex.synchronize {(queue.empty?) ? nil : queue.pop(true)}
|
|
93
93
|
if cid
|
|
94
94
|
retry_count = 0
|
|
95
|
-
file_name =
|
|
95
|
+
file_name = 'adgroup_%010d.csv' % cid
|
|
96
96
|
puts "[%2d/%d] Loading report for customer ID %s into '%s'..." %
|
|
97
97
|
[thread_id, retry_count,
|
|
98
98
|
AdwordsApi::Utils.format_id(cid), file_name]
|
|
@@ -105,8 +105,8 @@ def parallel_report_download()
|
|
|
105
105
|
sleep(retry_count * BACKOFF_FACTOR)
|
|
106
106
|
retry
|
|
107
107
|
else
|
|
108
|
-
puts((
|
|
109
|
-
|
|
108
|
+
puts(('Report failed for customer ID %s with code %d after %d ' +
|
|
109
|
+
'retries.') % [cid, e.http_code, retry_count + 1])
|
|
110
110
|
reports_failed <<
|
|
111
111
|
{:cid => cid, :http_code => e.http_code, :message => e.message}
|
|
112
112
|
end
|
|
@@ -150,10 +150,10 @@ if __FILE__ == $0
|
|
|
150
150
|
|
|
151
151
|
# HTTP errors.
|
|
152
152
|
rescue AdsCommon::Errors::HttpError => e
|
|
153
|
-
puts
|
|
153
|
+
puts 'HTTP Error: %s' % e
|
|
154
154
|
|
|
155
155
|
# API errors.
|
|
156
156
|
rescue AdwordsApi::Errors::ReportError => e
|
|
157
|
-
puts
|
|
157
|
+
puts 'Reporting Error: %s' % e.message
|
|
158
158
|
end
|
|
159
159
|
end
|
data/lib/adwords_api.rb
CHANGED
|
@@ -54,24 +54,20 @@ module AdwordsApi
|
|
|
54
54
|
# - auth_handler: instance of an AdsCommon::Auth::BaseHandler subclass to
|
|
55
55
|
# handle authentication
|
|
56
56
|
# - version: intended API version
|
|
57
|
-
# -
|
|
57
|
+
# - header_ns: header namespace
|
|
58
|
+
# - default_ns: default namespace
|
|
58
59
|
#
|
|
59
60
|
# Returns:
|
|
60
|
-
# -
|
|
61
|
+
# - SOAP header handler
|
|
61
62
|
#
|
|
62
|
-
def soap_header_handler(auth_handler, version,
|
|
63
|
+
def soap_header_handler(auth_handler, version, header_ns, default_ns)
|
|
63
64
|
auth_method = @config.read('authentication.method', :CLIENTLOGIN)
|
|
64
|
-
|
|
65
|
-
when :CLIENTLOGIN
|
|
66
|
-
|
|
67
|
-
version.to_s
|
|
68
|
-
AdwordsApi::ClientLoginHeaderHandler.new(
|
|
69
|
-
@credential_handler, auth_handler, namespace, auth_ns, version)
|
|
70
|
-
when :OAUTH, :OAUTH2
|
|
71
|
-
AdsCommon::SavonHeaders::OAuthHeaderHandler.new(
|
|
72
|
-
@credential_handler, auth_handler, namespace, version)
|
|
65
|
+
handler_class = case auth_method
|
|
66
|
+
when :CLIENTLOGIN then AdwordsApi::ClientLoginHeaderHandler
|
|
67
|
+
when :OAUTH, :OAUTH2 then AdsCommon::SavonHeaders::OAuthHeaderHandler
|
|
73
68
|
end
|
|
74
|
-
return
|
|
69
|
+
return handler_class.new(@credential_handler, auth_handler, header_ns,
|
|
70
|
+
default_ns, version)
|
|
75
71
|
end
|
|
76
72
|
|
|
77
73
|
# Helper method to provide a simple way of doing an MCC-level operation
|
|
@@ -142,12 +142,14 @@ module AdwordsApi
|
|
|
142
142
|
@@environment_config = {
|
|
143
143
|
:PRODUCTION => {
|
|
144
144
|
:oauth_scope => 'https://adwords.google.com/api/adwords/',
|
|
145
|
+
:header_ns => 'https://adwords.google.com/api/adwords/cm/',
|
|
145
146
|
:v201109 => 'https://adwords.google.com/api/adwords/',
|
|
146
147
|
:v201109_1 => 'https://adwords.google.com/api/adwords/',
|
|
147
148
|
:v201206 => 'https://adwords.google.com/api/adwords/'
|
|
148
149
|
},
|
|
149
150
|
:SANDBOX => {
|
|
150
151
|
:oauth_scope => 'https://adwords-sandbox.google.com/api/adwords/',
|
|
152
|
+
:header_ns => 'https://adwords.google.com/api/adwords/cm/',
|
|
151
153
|
:v201109 => 'https://adwords-sandbox.google.com/api/adwords/',
|
|
152
154
|
:v201109_1 => 'https://adwords-sandbox.google.com/api/adwords/',
|
|
153
155
|
:v201206 => 'https://adwords-sandbox.google.com/api/adwords/'
|
|
@@ -240,7 +242,6 @@ module AdwordsApi
|
|
|
240
242
|
[:v201206, :MediaService] => 'cm/',
|
|
241
243
|
[:v201206, :MutateJobService] => 'cm/',
|
|
242
244
|
[:v201206, :ReportDefinitionService] => 'cm/',
|
|
243
|
-
[:v201206, :ServicedAccountService] => 'mcm/',
|
|
244
245
|
[:v201206, :TargetingIdeaService] => 'o/',
|
|
245
246
|
[:v201206, :TrafficEstimatorService] => 'o/',
|
|
246
247
|
[:v201206, :UserListService] => 'cm/',
|
|
@@ -251,8 +252,6 @@ module AdwordsApi
|
|
|
251
252
|
# Auth constants for ClientLogin method.
|
|
252
253
|
@@client_login_config = {
|
|
253
254
|
:AUTH_SERVER => 'https://www.google.com',
|
|
254
|
-
:AUTH_NAMESPACE_PREAMBLE =>
|
|
255
|
-
'https://adwords.google.com/api/adwords/cm/',
|
|
256
255
|
:LOGIN_SERVICE_NAME => 'adwords'
|
|
257
256
|
}
|
|
258
257
|
|
|
@@ -23,55 +23,8 @@ require 'ads_common/savon_headers/base_header_handler'
|
|
|
23
23
|
|
|
24
24
|
module AdwordsApi
|
|
25
25
|
class ClientLoginHeaderHandler < AdsCommon::SavonHeaders::BaseHeaderHandler
|
|
26
|
-
# Initializes a header handler.
|
|
27
|
-
#
|
|
28
|
-
# Args:
|
|
29
|
-
# - credential_handler: a header with credential data
|
|
30
|
-
# - auth_handler: a header with auth data
|
|
31
|
-
# - element_name: an API-specific name of header element
|
|
32
|
-
# - namespace: default namespace to use
|
|
33
|
-
# - auth_namespace: namespace to use for auth headers
|
|
34
|
-
# - version: services version
|
|
35
|
-
#
|
|
36
|
-
def initialize(credential_handler, auth_handler, namespace, auth_namespace,
|
|
37
|
-
version)
|
|
38
|
-
super(credential_handler, auth_handler, namespace, version)
|
|
39
|
-
@auth_namespace = auth_namespace
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Enriches soap object with API-specific headers like namespaces, login
|
|
43
|
-
# credentials etc. Sets the default namespace for the body to the one
|
|
44
|
-
# specified in initializer.
|
|
45
|
-
#
|
|
46
|
-
# Args:
|
|
47
|
-
# - request: a HTTPI Request for extra configuration (unused)
|
|
48
|
-
# - soap: a Savon soap object to fill fields in
|
|
49
|
-
#
|
|
50
|
-
# Returns:
|
|
51
|
-
# - modified soap structure
|
|
52
|
-
#
|
|
53
|
-
def prepare_request(request, soap)
|
|
54
|
-
super(request, soap)
|
|
55
|
-
soap.header[:attributes!] ||= {}
|
|
56
|
-
header_name = prepend_namespace(get_header_element_name())
|
|
57
|
-
soap.header[:attributes!][header_name] ||= {}
|
|
58
|
-
soap.header[:attributes!][header_name]['xmlns'] = @auth_namespace
|
|
59
|
-
return soap
|
|
60
|
-
end
|
|
61
26
|
|
|
62
27
|
private
|
|
63
|
-
# Skips namespace prefixes for all elements except top level. Use default
|
|
64
|
-
# (inherited) prefixing for the top level key.
|
|
65
|
-
#
|
|
66
|
-
# Args:
|
|
67
|
-
# - str: String to prepend with a namespace
|
|
68
|
-
#
|
|
69
|
-
# Returns:
|
|
70
|
-
# - String with a namespace
|
|
71
|
-
#
|
|
72
|
-
def prepend_namespace(str)
|
|
73
|
-
return get_header_element_name().eql?(str) ? super(str) : str
|
|
74
|
-
end
|
|
75
28
|
|
|
76
29
|
# Generates AdWords API specific request header with ClientLogin data.
|
|
77
30
|
def generate_request_header()
|