google-adx-buyer-api 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +7 -0
- data/README +43 -41
- data/Rakefile +3 -3
- data/examples/v201003/add_ad_group.rb +5 -5
- data/examples/v201003/add_ad_group_criteria.rb +5 -5
- data/examples/v201003/add_ads.rb +5 -5
- data/examples/v201003/add_campaign.rb +5 -5
- data/examples/v201003/add_negative_campaign_criterion.rb +5 -5
- data/examples/v201003/add_placement_performance_report_definition.rb +5 -5
- data/examples/v201003/check_campaigns.rb +5 -5
- data/examples/v201003/delete_ad.rb +5 -5
- data/examples/v201003/delete_ad_group.rb +5 -5
- data/examples/v201003/delete_ad_group_criterion.rb +5 -5
- data/examples/v201003/delete_campaign.rb +5 -5
- data/examples/v201003/download_report.rb +5 -0
- data/examples/v201003/get_all_active_ad_group_criteria.rb +5 -5
- data/examples/v201003/get_all_ad_group_criteria.rb +5 -5
- data/examples/v201003/get_all_ad_groups.rb +5 -5
- data/examples/v201003/get_all_ads.rb +5 -5
- data/examples/v201003/get_all_campaign_targets.rb +5 -5
- data/examples/v201003/get_all_campaigns.rb +5 -5
- data/examples/v201003/get_all_disapproved_ads.rb +5 -5
- data/examples/v201003/get_all_images.rb +5 -5
- data/examples/v201003/get_all_paused_campaigns.rb +5 -5
- data/examples/v201003/get_all_report_definitions.rb +5 -5
- data/examples/v201003/get_criterion_bid_landscape.rb +5 -5
- data/examples/v201003/get_geo_location_info.rb +5 -5
- data/examples/v201003/get_related_placements.rb +5 -5
- data/examples/v201003/get_report_fields.rb +5 -5
- data/examples/v201003/perform_bulk_mutate_job.rb +5 -5
- data/examples/v201003/set_campaign_targets.rb +5 -5
- data/examples/v201003/update_ad.rb +5 -5
- data/examples/v201003/update_ad_group.rb +5 -5
- data/examples/v201003/update_ad_group_criterion.rb +5 -5
- data/examples/v201003/update_campaign.rb +5 -5
- data/examples/v201003/upload_image.rb +5 -5
- data/examples/v201008/add_ad_group.rb +5 -5
- data/examples/v201008/add_ad_group_criteria.rb +5 -5
- data/examples/v201008/add_ads.rb +5 -5
- data/examples/v201008/add_campaign.rb +5 -5
- data/examples/v201008/add_negative_campaign_criterion.rb +5 -5
- data/examples/v201008/add_placement_performance_report_definition.rb +5 -5
- data/examples/v201008/add_user_list.rb +5 -5
- data/examples/v201008/check_campaigns.rb +5 -5
- data/examples/v201008/delete_ad.rb +5 -5
- data/examples/v201008/delete_ad_group.rb +5 -5
- data/examples/v201008/delete_ad_group_criterion.rb +5 -5
- data/examples/v201008/delete_bulk_mutate_job.rb +5 -5
- data/examples/v201008/delete_campaign.rb +5 -5
- data/examples/v201008/delete_user_list.rb +5 -5
- data/examples/v201008/download_report.rb +5 -0
- data/examples/v201008/get_all_account_changes.rb +5 -5
- data/examples/v201008/get_all_active_ad_group_criteria.rb +5 -5
- data/examples/v201008/get_all_ad_group_criteria.rb +5 -5
- data/examples/v201008/get_all_ad_groups.rb +5 -5
- data/examples/v201008/get_all_ads.rb +5 -5
- data/examples/v201008/get_all_campaign_targets.rb +5 -5
- data/examples/v201008/get_all_campaigns.rb +5 -5
- data/examples/v201008/get_all_disapproved_ads.rb +5 -5
- data/examples/v201008/get_all_images.rb +5 -5
- data/examples/v201008/get_all_paused_campaigns.rb +5 -5
- data/examples/v201008/get_all_report_definitions.rb +5 -5
- data/examples/v201008/get_all_user_lists.rb +5 -5
- data/examples/v201008/get_bulk_mutate_job.rb +5 -5
- data/examples/v201008/get_campaign_alerts.rb +5 -5
- data/examples/v201008/get_criterion_bid_landscape.rb +5 -5
- data/examples/v201008/get_geo_location_info.rb +5 -5
- data/examples/v201008/get_related_placements.rb +5 -5
- data/examples/v201008/get_report_fields.rb +5 -5
- data/examples/v201008/perform_bulk_mutate_job.rb +5 -5
- data/examples/v201008/set_campaign_targets.rb +5 -5
- data/examples/v201008/update_ad.rb +5 -5
- data/examples/v201008/update_ad_group.rb +5 -5
- data/examples/v201008/update_ad_group_criterion.rb +5 -5
- data/examples/v201008/update_campaign.rb +5 -5
- data/examples/v201008/update_user_list.rb +5 -5
- data/examples/v201008/upload_image.rb +5 -5
- data/examples/v201101/add_ad_group.rb +5 -5
- data/examples/v201101/add_ad_group_criteria.rb +5 -5
- data/examples/v201101/add_ads.rb +5 -5
- data/examples/v201101/add_campaign.rb +5 -5
- data/examples/v201101/add_conversion.rb +5 -5
- data/examples/v201101/add_negative_campaign_criterion.rb +5 -5
- data/examples/v201101/add_placement_performance_report_definition.rb +5 -5
- data/examples/v201101/add_rtb_campaign.rb +5 -5
- data/examples/v201101/add_user_list.rb +5 -5
- data/examples/v201101/check_campaigns.rb +5 -5
- data/examples/v201101/delete_ad.rb +5 -5
- data/examples/v201101/delete_ad_group.rb +5 -5
- data/examples/v201101/delete_ad_group_criterion.rb +5 -5
- data/examples/v201101/delete_bulk_mutate_job.rb +5 -5
- data/examples/v201101/delete_campaign.rb +5 -5
- data/examples/v201101/delete_user_list.rb +5 -5
- data/examples/v201101/download_report.rb +5 -0
- data/examples/v201101/get_ad_group_bid_landscape.rb +5 -5
- data/examples/v201101/get_all_account_changes.rb +5 -5
- data/examples/v201101/get_all_active_ad_group_criteria.rb +5 -5
- data/examples/v201101/get_all_ad_group_criteria.rb +5 -5
- data/examples/v201101/get_all_ad_groups.rb +5 -5
- data/examples/v201101/get_all_ads.rb +5 -5
- data/examples/v201101/get_all_campaign_targets.rb +5 -5
- data/examples/v201101/get_all_campaigns.rb +5 -5
- data/examples/v201101/get_all_conversions.rb +5 -5
- data/examples/v201101/get_all_disapproved_ads.rb +5 -5
- data/examples/v201101/get_all_images.rb +5 -5
- data/examples/v201101/get_all_paused_campaigns.rb +5 -5
- data/examples/v201101/get_all_report_definitions.rb +5 -5
- data/examples/v201101/get_all_user_lists.rb +5 -5
- data/examples/v201101/get_bulk_mutate_job.rb +5 -5
- data/examples/v201101/get_campaign_alerts.rb +5 -5
- data/examples/v201101/get_criterion_bid_landscape.rb +5 -5
- data/examples/v201101/get_geo_location_info.rb +5 -5
- data/examples/v201101/get_related_placements.rb +5 -5
- data/examples/v201101/get_report_fields.rb +5 -5
- data/examples/v201101/perform_bulk_mutate_job.rb +5 -5
- data/examples/v201101/set_campaign_targets.rb +5 -5
- data/examples/v201101/update_ad.rb +5 -5
- data/examples/v201101/update_ad_group.rb +5 -5
- data/examples/v201101/update_ad_group_criterion.rb +5 -5
- data/examples/v201101/update_campaign.rb +5 -5
- data/examples/v201101/update_conversion.rb +5 -5
- data/examples/v201101/update_user_list.rb +5 -5
- data/examples/v201101/upload_image.rb +5 -5
- data/examples/v201109/add_ad_group.rb +98 -0
- data/examples/v201109/add_ad_group_criteria.rb +100 -0
- data/examples/v201109/add_ads.rb +110 -0
- data/examples/v201109/add_campaign.rb +108 -0
- data/examples/v201109/add_campaign_targeting_criteria.rb +102 -0
- data/examples/v201109/add_conversion.rb +97 -0
- data/examples/{v201008/get_all_experiments.rb → v201109/add_negative_campaign_criterion.rb} +32 -30
- data/examples/v201109/add_rtb_campaign.rb +113 -0
- data/examples/v201109/add_user_list.rb +122 -0
- data/examples/v201109/check_campaigns.rb +132 -0
- data/examples/v201109/delete_ad.rb +94 -0
- data/examples/{v201101/delete_experiment.rb → v201109/delete_ad_group.rb} +20 -21
- data/examples/v201109/delete_ad_group_criterion.rb +95 -0
- data/examples/v201109/delete_bulk_mutate_job.rb +96 -0
- data/examples/{v201008/delete_experiment.rb → v201109/delete_campaign.rb} +21 -21
- data/examples/{v201008/promote_experiment.rb → v201109/delete_user_list.rb} +21 -22
- data/examples/v201109/download_adhoc_report.rb +79 -0
- data/examples/v201109/download_report.rb +76 -0
- data/examples/v201109/get_ad_group_bid_landscape.rb +103 -0
- data/examples/v201109/get_all_account_changes.rb +146 -0
- data/examples/v201109/get_all_active_ad_group_criteria.rb +106 -0
- data/examples/v201109/get_all_ad_group_criteria.rb +98 -0
- data/examples/{v201101/get_all_experiments.rb → v201109/get_all_ad_groups.rb} +21 -25
- data/examples/v201109/get_all_ads.rb +99 -0
- data/examples/v201109/get_all_campaign_targets.rb +83 -0
- data/examples/v201109/get_all_campaigns.rb +86 -0
- data/examples/v201109/get_all_carriers.rb +72 -0
- data/examples/v201109/get_all_conversions.rb +88 -0
- data/examples/v201109/get_all_disapproved_ads.rb +102 -0
- data/examples/v201109/get_all_images.rb +90 -0
- data/examples/v201109/get_all_languages.rb +73 -0
- data/examples/v201109/get_all_paused_campaigns.rb +92 -0
- data/examples/v201109/get_all_report_definitions.rb +84 -0
- data/examples/v201109/get_all_user_lists.rb +87 -0
- data/examples/v201109/get_bulk_mutate_job.rb +106 -0
- data/examples/v201109/get_campaign_alerts.rb +103 -0
- data/examples/v201109/get_client_customer_id.rb +87 -0
- data/examples/v201109/get_criterion_bid_landscape.rb +102 -0
- data/examples/v201109/get_geo_location_info.rb +108 -0
- data/examples/v201109/get_location_criteria.rb +103 -0
- data/examples/v201109/get_related_placements.rb +114 -0
- data/examples/v201109/get_report_fields.rb +81 -0
- data/examples/v201109/perform_bulk_mutate_job.rb +222 -0
- data/examples/v201109/perform_mutate_job.rb +151 -0
- data/examples/{v201101/promote_experiment.rb → v201109/update_ad.rb} +29 -22
- data/examples/v201109/update_ad_group.rb +90 -0
- data/examples/v201109/update_ad_group_criterion.rb +108 -0
- data/examples/v201109/update_campaign.rb +93 -0
- data/examples/v201109/update_conversion.rb +96 -0
- data/examples/v201109/update_user_list.rb +91 -0
- data/examples/v201109/upload_image.rb +97 -0
- metadata +164 -114
- data/examples/v201008/add_experiment.rb +0 -162
- data/examples/v201101/add_experiment.rb +0 -162
@@ -17,28 +17,33 @@
|
|
17
17
|
# See the License for the specific language governing permissions and
|
18
18
|
# limitations under the License.
|
19
19
|
#
|
20
|
-
# This example
|
21
|
-
#
|
20
|
+
# This example illustrates how to retrieve all the ad groups for a campaign. To
|
21
|
+
# create an ad group, run add_ad_group.rb.
|
22
22
|
#
|
23
|
-
# Tags:
|
23
|
+
# Tags: AdGroupService.get
|
24
24
|
|
25
25
|
require 'rubygems'
|
26
26
|
gem 'google-adwords-api'
|
27
27
|
require 'adwords_api'
|
28
28
|
|
29
|
-
API_VERSION = :
|
29
|
+
API_VERSION = :v201109
|
30
30
|
|
31
|
-
def
|
31
|
+
def get_all_ad_groups()
|
32
32
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
33
33
|
# when called without parameters.
|
34
34
|
adwords = AdwordsApi::Api.new
|
35
|
-
|
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
|
+
ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
|
36
41
|
|
37
42
|
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
38
43
|
|
39
|
-
# Get all the
|
44
|
+
# Get all the ad groups for this campaign.
|
40
45
|
selector = {
|
41
|
-
:fields => ['Id', 'Name'
|
46
|
+
:fields => ['Id', 'Name'],
|
42
47
|
:ordering => [{:field => 'Name', :sort_order => 'ASCENDING'}],
|
43
48
|
:predicates => [{
|
44
49
|
:field => 'CampaignId',
|
@@ -46,31 +51,22 @@ def get_all_experiments()
|
|
46
51
|
:values => [campaign_id]
|
47
52
|
}]
|
48
53
|
}
|
49
|
-
response =
|
50
|
-
|
54
|
+
response = ad_group_srv.get(selector)
|
51
55
|
if response and response[:entries]
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
puts "
|
56
|
-
"
|
57
|
-
"#{experiment[:control_id]} was found and it includes " +
|
58
|
-
"#{experiment_stats[:ad_groups_count]} ad group(s) and " +
|
59
|
-
"#{experiment_stats[:ad_group_criteria_count]} criteria.\n"
|
56
|
+
ad_groups = response[:entries]
|
57
|
+
puts "Campaign ##{campaign_id} has #{ad_groups.length} ad group(s)."
|
58
|
+
ad_groups.each do |ad_group|
|
59
|
+
puts " Ad group name is \"#{ad_group[:name]}\" and id is " +
|
60
|
+
"#{ad_group[:id]}."
|
60
61
|
end
|
61
62
|
else
|
62
|
-
puts "No
|
63
|
+
puts "No ad groups found for campaign ##{campaign_id}."
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
66
67
|
if __FILE__ == $0
|
67
|
-
# To enable logging of SOAP requests, set the ADWORDSAPI_DEBUG environment
|
68
|
-
# variable to 'true'. This can be done either from your operating system
|
69
|
-
# environment or via code, as done below.
|
70
|
-
ENV['ADWORDSAPI_DEBUG'] = 'false'
|
71
|
-
|
72
68
|
begin
|
73
|
-
|
69
|
+
get_all_ad_groups()
|
74
70
|
|
75
71
|
# Connection error. Likely transitory.
|
76
72
|
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Author:: api.sgomes@gmail.com (Sérgio Gomes)
|
4
|
+
#
|
5
|
+
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
6
|
+
#
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
# This example illustrates how to retrieve all the ads for an ad group. To add
|
21
|
+
# ads to an existing ad group, run add_ads.rb.
|
22
|
+
#
|
23
|
+
# Tags: AdGroupAdService.get
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
gem 'google-adwords-api'
|
27
|
+
require 'adwords_api'
|
28
|
+
|
29
|
+
API_VERSION = :v201109
|
30
|
+
|
31
|
+
def get_all_ads()
|
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
|
+
ad_group_ad_srv = adwords.service(:AdGroupAdService, API_VERSION)
|
41
|
+
|
42
|
+
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
43
|
+
|
44
|
+
# Get all the ads for this ad group.
|
45
|
+
selector = {
|
46
|
+
:fields => ['Id', 'Status'],
|
47
|
+
:ordering => [{:field => 'Id', :sort_order => 'ASCENDING'}],
|
48
|
+
# By default, disabled ads aren't returned by the selector. To return them,
|
49
|
+
# include the DISABLED status in a predicate.
|
50
|
+
:predicates => [
|
51
|
+
{:field => 'AdGroupId', :operator => 'IN', :values => [ad_group_id]},
|
52
|
+
{
|
53
|
+
:field => 'Status',
|
54
|
+
:operator => 'IN',
|
55
|
+
:values => ['ENABLED', 'PAUSED', 'DISABLED']
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
59
|
+
response = ad_group_ad_srv.get(selector)
|
60
|
+
if response and response[:entries]
|
61
|
+
ads = response[:entries]
|
62
|
+
puts "Ad group ##{ad_group_id} has #{ads.length} ad(s)."
|
63
|
+
ads.each do |ad|
|
64
|
+
puts " Ad id is #{ad[:ad][:id]}, type is #{ad[:ad][:xsi_type]} and " +
|
65
|
+
"status is \"#{ad[:status]}\"."
|
66
|
+
end
|
67
|
+
else
|
68
|
+
puts "No ads found for ad group ##{ad_group_id}."
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
if __FILE__ == $0
|
73
|
+
begin
|
74
|
+
get_all_ads()
|
75
|
+
|
76
|
+
# Connection error. Likely transitory.
|
77
|
+
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
78
|
+
puts 'Connection Error: %s' % e
|
79
|
+
puts 'Source: %s' % e.backtrace.first
|
80
|
+
|
81
|
+
# API Error.
|
82
|
+
rescue AdwordsApi::Errors::ApiException => e
|
83
|
+
puts 'API Exception caught.'
|
84
|
+
puts 'Message: %s' % e.message
|
85
|
+
puts 'Code: %d' % e.code if e.code
|
86
|
+
puts 'Trigger: %s' % e.trigger if e.trigger
|
87
|
+
puts 'Errors:'
|
88
|
+
if e.errors
|
89
|
+
e.errors.each_with_index do |error, index|
|
90
|
+
puts ' %d. Error type is %s. Fields:' % [index + 1, error[:xsi_type]]
|
91
|
+
error.each_pair do |field, value|
|
92
|
+
if field != :xsi_type
|
93
|
+
puts ' %s: %s' % [field, value]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Author:: api.sgomes@gmail.com (Sérgio Gomes)
|
4
|
+
#
|
5
|
+
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
6
|
+
#
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
# This example illustrates how to retrieve all the campaign targets. To set
|
21
|
+
# campaign targets, run set_campaign_targets.rb.
|
22
|
+
#
|
23
|
+
# Tags: CampaignTargetService.get
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
gem 'google-adwords-api'
|
27
|
+
require 'adwords_api'
|
28
|
+
|
29
|
+
API_VERSION = :v201109
|
30
|
+
|
31
|
+
def get_all_campaign_targets()
|
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
|
+
campaign_target_srv = adwords.service(:CampaignTargetService, API_VERSION)
|
41
|
+
|
42
|
+
# Get all the campaign targets for this account.
|
43
|
+
selector = {}
|
44
|
+
response = campaign_target_srv.get(selector)
|
45
|
+
if response and response[:entries]
|
46
|
+
targets = response[:entries]
|
47
|
+
targets.each do |target|
|
48
|
+
puts "Campaign target of type #{target[:xsi_type]} for campaign " +
|
49
|
+
"id #{target[:campaign_id]} was set."
|
50
|
+
end
|
51
|
+
else
|
52
|
+
puts "No campaign targets found."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if __FILE__ == $0
|
57
|
+
begin
|
58
|
+
get_all_campaign_targets()
|
59
|
+
|
60
|
+
# Connection error. Likely transitory.
|
61
|
+
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
62
|
+
puts 'Connection Error: %s' % e
|
63
|
+
puts 'Source: %s' % e.backtrace.first
|
64
|
+
|
65
|
+
# API Error.
|
66
|
+
rescue AdwordsApi::Errors::ApiException => e
|
67
|
+
puts 'API Exception caught.'
|
68
|
+
puts 'Message: %s' % e.message
|
69
|
+
puts 'Code: %d' % e.code if e.code
|
70
|
+
puts 'Trigger: %s' % e.trigger if e.trigger
|
71
|
+
puts 'Errors:'
|
72
|
+
if e.errors
|
73
|
+
e.errors.each_with_index do |error, index|
|
74
|
+
puts ' %d. Error type is %s. Fields:' % [index + 1, error[:xsi_type]]
|
75
|
+
error.each_pair do |field, value|
|
76
|
+
if field != :xsi_type
|
77
|
+
puts ' %s: %s' % [field, value]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Author:: api.sgomes@gmail.com (Sérgio Gomes)
|
4
|
+
#
|
5
|
+
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
6
|
+
#
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
# This example illustrates how to retrieve all the campaigns for an account.
|
21
|
+
#
|
22
|
+
# Tags: CampaignService.get
|
23
|
+
|
24
|
+
require 'rubygems'
|
25
|
+
gem 'google-adwords-api'
|
26
|
+
require 'adwords_api'
|
27
|
+
|
28
|
+
API_VERSION = :v201109
|
29
|
+
|
30
|
+
def get_all_campaigns()
|
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
|
+
campaign_srv = adwords.service(:CampaignService, API_VERSION)
|
40
|
+
|
41
|
+
# Get all the campaigns for this account; empty selector.
|
42
|
+
selector = {
|
43
|
+
:fields => ['Id', 'Name', 'Status'],
|
44
|
+
:ordering => [{:field => 'Name', :sort_order => 'ASCENDING'}]
|
45
|
+
}
|
46
|
+
response = campaign_srv.get(selector)
|
47
|
+
|
48
|
+
if response and response[:entries]
|
49
|
+
campaigns = response[:entries]
|
50
|
+
campaigns.each do |campaign|
|
51
|
+
puts "Campaign name is \"#{campaign[:name]}\", id is #{campaign[:id]} " +
|
52
|
+
"and status is \"#{campaign[:status]}\"."
|
53
|
+
end
|
54
|
+
else
|
55
|
+
puts "No campaigns were found."
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
if __FILE__ == $0
|
60
|
+
begin
|
61
|
+
get_all_campaigns()
|
62
|
+
|
63
|
+
# Connection error. Likely transitory.
|
64
|
+
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
65
|
+
puts 'Connection Error: %s' % e
|
66
|
+
puts 'Source: %s' % e.backtrace.first
|
67
|
+
|
68
|
+
# API Error.
|
69
|
+
rescue AdwordsApi::Errors::ApiException => e
|
70
|
+
puts 'API Exception caught.'
|
71
|
+
puts 'Message: %s' % e.message
|
72
|
+
puts 'Code: %d' % e.code if e.code
|
73
|
+
puts 'Trigger: %s' % e.trigger if e.trigger
|
74
|
+
puts 'Errors:'
|
75
|
+
if e.errors
|
76
|
+
e.errors.each_with_index do |error, index|
|
77
|
+
puts ' %d. Error type is %s. Fields:' % [index + 1, error[:xsi_type]]
|
78
|
+
error.each_pair do |field, value|
|
79
|
+
if field != :xsi_type
|
80
|
+
puts ' %s: %s' % [field, value]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
4
|
+
#
|
5
|
+
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
6
|
+
#
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
# This example illustrates how to retrieve all carriers available for targeting.
|
21
|
+
#
|
22
|
+
# Tags: ConstantDataService.getCarrierCriterion
|
23
|
+
|
24
|
+
require 'rubygems'
|
25
|
+
require 'adwords_api'
|
26
|
+
|
27
|
+
API_VERSION = :v201109
|
28
|
+
|
29
|
+
def get_all_carriers()
|
30
|
+
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
31
|
+
# when called without parameters.
|
32
|
+
adwords = AdwordsApi::Api.new
|
33
|
+
|
34
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
35
|
+
# the configuration file or provide your own logger:
|
36
|
+
# adwords.logger = Logger.new('adwords_xml.log')
|
37
|
+
|
38
|
+
constant_data_srv = adwords.service(:ConstantDataService, API_VERSION)
|
39
|
+
|
40
|
+
# Get all carriers from ConstantDataService.
|
41
|
+
carriers = constant_data_srv.get_carrier_criterion()
|
42
|
+
|
43
|
+
if carriers
|
44
|
+
carriers.each do |carrier|
|
45
|
+
puts "Carrier name is '%s', ID is %d and country code is '%s'." %
|
46
|
+
[carrier[:name], carrier[:id], carrier[:country_code]]
|
47
|
+
end
|
48
|
+
else
|
49
|
+
puts 'No carriers were retrieved.'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
if __FILE__ == $0
|
54
|
+
begin
|
55
|
+
get_all_carriers()
|
56
|
+
|
57
|
+
# HTTP errors.
|
58
|
+
rescue AdsCommon::Errors::HttpError => e
|
59
|
+
puts "HTTP Error: %s" % e
|
60
|
+
|
61
|
+
# API errors.
|
62
|
+
rescue AdwordsApi::Errors::ApiException => e
|
63
|
+
puts "Message: %s" % e.message
|
64
|
+
puts 'Errors:'
|
65
|
+
e.errors.each_with_index do |error, index|
|
66
|
+
puts "\tError [%d]:" % (index + 1)
|
67
|
+
error.each do |field, value|
|
68
|
+
puts "\t\t%s: %s" % [field, value]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Author:: api.sgomes@gmail.com (Sérgio Gomes)
|
4
|
+
#
|
5
|
+
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
6
|
+
#
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
# This example gets all conversions in the account. To add conversions, run
|
21
|
+
# add_conversion.rb.
|
22
|
+
#
|
23
|
+
# Tags: ConversionTrackerService.get
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
gem 'google-adwords-api'
|
27
|
+
require 'adwords_api'
|
28
|
+
|
29
|
+
API_VERSION = :v201109
|
30
|
+
|
31
|
+
def get_all_conversions()
|
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
|
+
conv_tracker_srv = adwords.service(:ConversionTrackerService, API_VERSION)
|
41
|
+
|
42
|
+
# Get all conversions.
|
43
|
+
selector = {
|
44
|
+
:fields => ['Id', 'Name', 'Status', 'Category'],
|
45
|
+
:ordering => [{:field => 'Name', :sort_order => 'ASCENDING'}],
|
46
|
+
}
|
47
|
+
response = conv_tracker_srv.get(selector)
|
48
|
+
if response and response[:entries]
|
49
|
+
conversions = response[:entries]
|
50
|
+
puts "#{conversions.length} conversions(s) found."
|
51
|
+
conversions.each do |conversion|
|
52
|
+
puts " Conversion with id \"#{conversion[:id]}\", status \"" +
|
53
|
+
"#{conversion[:status]}\" and category \"#{conversion[:category]}\"" +
|
54
|
+
" was found. Code snippet: \n#{conversion[:snippet]}\n"
|
55
|
+
end
|
56
|
+
else
|
57
|
+
puts "No conversions found."
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
if __FILE__ == $0
|
62
|
+
begin
|
63
|
+
get_all_conversions()
|
64
|
+
|
65
|
+
# Connection error. Likely transitory.
|
66
|
+
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
67
|
+
puts 'Connection Error: %s' % e
|
68
|
+
puts 'Source: %s' % e.backtrace.first
|
69
|
+
|
70
|
+
# API Error.
|
71
|
+
rescue AdwordsApi::Errors::ApiException => e
|
72
|
+
puts 'API Exception caught.'
|
73
|
+
puts 'Message: %s' % e.message
|
74
|
+
puts 'Code: %d' % e.code if e.code
|
75
|
+
puts 'Trigger: %s' % e.trigger if e.trigger
|
76
|
+
puts 'Errors:'
|
77
|
+
if e.errors
|
78
|
+
e.errors.each_with_index do |error, index|
|
79
|
+
puts ' %d. Error type is %s. Fields:' % [index + 1, error[:xsi_type]]
|
80
|
+
error.each_pair do |field, value|
|
81
|
+
if field != :xsi_type
|
82
|
+
puts ' %s: %s' % [field, value]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|