google-adx-buyer-api 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +201 -0
- data/ChangeLog +2 -0
- data/README +208 -0
- data/Rakefile +50 -0
- data/examples/v201003/add_ad_group.rb +98 -0
- data/examples/v201003/add_ad_group_criteria.rb +100 -0
- data/examples/v201003/add_ads.rb +110 -0
- data/examples/v201003/add_campaign.rb +101 -0
- data/examples/v201003/add_negative_campaign_criterion.rb +95 -0
- data/examples/v201003/add_placement_performance_report_definition.rb +108 -0
- data/examples/v201003/check_campaigns.rb +132 -0
- data/examples/v201003/delete_ad.rb +94 -0
- data/examples/v201003/delete_ad_group.rb +86 -0
- data/examples/v201003/delete_ad_group_criterion.rb +95 -0
- data/examples/v201003/delete_campaign.rb +87 -0
- data/examples/v201003/download_report.rb +71 -0
- data/examples/v201003/get_all_active_ad_group_criteria.rb +93 -0
- data/examples/v201003/get_all_ad_group_criteria.rb +91 -0
- data/examples/v201003/get_all_ad_groups.rb +88 -0
- data/examples/v201003/get_all_ads.rb +91 -0
- data/examples/v201003/get_all_campaign_targets.rb +83 -0
- data/examples/v201003/get_all_campaigns.rb +83 -0
- data/examples/v201003/get_all_disapproved_ads.rb +94 -0
- data/examples/v201003/get_all_images.rb +88 -0
- data/examples/v201003/get_all_paused_campaigns.rb +86 -0
- data/examples/v201003/get_all_report_definitions.rb +84 -0
- data/examples/v201003/get_criterion_bid_landscape.rb +105 -0
- data/examples/v201003/get_geo_location_info.rb +108 -0
- data/examples/v201003/get_related_placements.rb +111 -0
- data/examples/v201003/get_report_fields.rb +81 -0
- data/examples/v201003/perform_bulk_mutate_job.rb +222 -0
- data/examples/v201003/set_campaign_targets.rb +124 -0
- data/examples/v201003/update_ad.rb +95 -0
- data/examples/v201003/update_ad_group.rb +90 -0
- data/examples/v201003/update_ad_group_criterion.rb +108 -0
- data/examples/v201003/update_campaign.rb +92 -0
- data/examples/v201003/upload_image.rb +97 -0
- data/examples/v201008/add_ad_group.rb +98 -0
- data/examples/v201008/add_ad_group_criteria.rb +100 -0
- data/examples/v201008/add_ads.rb +110 -0
- data/examples/v201008/add_campaign.rb +101 -0
- data/examples/v201008/add_experiment.rb +162 -0
- data/examples/v201008/add_negative_campaign_criterion.rb +95 -0
- data/examples/v201008/add_placement_performance_report_definition.rb +108 -0
- data/examples/v201008/add_user_list.rb +96 -0
- data/examples/v201008/check_campaigns.rb +132 -0
- data/examples/v201008/delete_ad.rb +94 -0
- data/examples/v201008/delete_ad_group.rb +86 -0
- data/examples/v201008/delete_ad_group_criterion.rb +95 -0
- data/examples/v201008/delete_bulk_mutate_job.rb +96 -0
- data/examples/v201008/delete_campaign.rb +87 -0
- data/examples/v201008/delete_experiment.rb +87 -0
- data/examples/v201008/delete_user_list.rb +87 -0
- data/examples/v201008/download_report.rb +71 -0
- data/examples/v201008/get_all_account_changes.rb +144 -0
- data/examples/v201008/get_all_active_ad_group_criteria.rb +93 -0
- data/examples/v201008/get_all_ad_group_criteria.rb +91 -0
- data/examples/v201008/get_all_ad_groups.rb +88 -0
- data/examples/v201008/get_all_ads.rb +91 -0
- data/examples/v201008/get_all_campaign_targets.rb +83 -0
- data/examples/v201008/get_all_campaigns.rb +83 -0
- data/examples/v201008/get_all_disapproved_ads.rb +94 -0
- data/examples/v201008/get_all_experiments.rb +93 -0
- data/examples/v201008/get_all_images.rb +88 -0
- data/examples/v201008/get_all_paused_campaigns.rb +86 -0
- data/examples/v201008/get_all_report_definitions.rb +84 -0
- data/examples/v201008/get_all_user_lists.rb +84 -0
- data/examples/v201008/get_bulk_mutate_job.rb +106 -0
- data/examples/v201008/get_campaign_alerts.rb +103 -0
- data/examples/v201008/get_criterion_bid_landscape.rb +105 -0
- data/examples/v201008/get_geo_location_info.rb +108 -0
- data/examples/v201008/get_related_placements.rb +114 -0
- data/examples/v201008/get_report_fields.rb +81 -0
- data/examples/v201008/perform_bulk_mutate_job.rb +222 -0
- data/examples/v201008/promote_experiment.rb +88 -0
- data/examples/v201008/set_campaign_targets.rb +124 -0
- data/examples/v201008/update_ad.rb +95 -0
- data/examples/v201008/update_ad_group.rb +90 -0
- data/examples/v201008/update_ad_group_criterion.rb +108 -0
- data/examples/v201008/update_campaign.rb +93 -0
- data/examples/v201008/update_user_list.rb +91 -0
- data/examples/v201008/upload_image.rb +97 -0
- data/examples/v201101/add_ad_group.rb +98 -0
- data/examples/v201101/add_ad_group_criteria.rb +100 -0
- data/examples/v201101/add_ads.rb +110 -0
- data/examples/v201101/add_campaign.rb +108 -0
- data/examples/v201101/add_conversion.rb +97 -0
- data/examples/v201101/add_experiment.rb +162 -0
- data/examples/v201101/add_negative_campaign_criterion.rb +95 -0
- data/examples/v201101/add_placement_performance_report_definition.rb +108 -0
- data/examples/v201101/add_rtb_campaign.rb +113 -0
- data/examples/v201101/add_user_list.rb +122 -0
- data/examples/v201101/check_campaigns.rb +132 -0
- data/examples/v201101/delete_ad.rb +94 -0
- data/examples/v201101/delete_ad_group.rb +86 -0
- data/examples/v201101/delete_ad_group_criterion.rb +95 -0
- data/examples/v201101/delete_bulk_mutate_job.rb +96 -0
- data/examples/v201101/delete_campaign.rb +87 -0
- data/examples/v201101/delete_experiment.rb +87 -0
- data/examples/v201101/delete_user_list.rb +87 -0
- data/examples/v201101/download_report.rb +71 -0
- data/examples/v201101/get_ad_group_bid_landscape.rb +103 -0
- data/examples/v201101/get_all_account_changes.rb +146 -0
- data/examples/v201101/get_all_active_ad_group_criteria.rb +106 -0
- data/examples/v201101/get_all_ad_group_criteria.rb +97 -0
- data/examples/v201101/get_all_ad_groups.rb +94 -0
- data/examples/v201101/get_all_ads.rb +99 -0
- data/examples/v201101/get_all_campaign_targets.rb +83 -0
- data/examples/v201101/get_all_campaigns.rb +86 -0
- data/examples/v201101/get_all_conversions.rb +88 -0
- data/examples/v201101/get_all_disapproved_ads.rb +102 -0
- data/examples/v201101/get_all_experiments.rb +98 -0
- data/examples/v201101/get_all_images.rb +90 -0
- data/examples/v201101/get_all_paused_campaigns.rb +92 -0
- data/examples/v201101/get_all_report_definitions.rb +84 -0
- data/examples/v201101/get_all_user_lists.rb +87 -0
- data/examples/v201101/get_bulk_mutate_job.rb +106 -0
- data/examples/v201101/get_campaign_alerts.rb +103 -0
- data/examples/v201101/get_criterion_bid_landscape.rb +102 -0
- data/examples/v201101/get_geo_location_info.rb +108 -0
- data/examples/v201101/get_related_placements.rb +114 -0
- data/examples/v201101/get_report_fields.rb +81 -0
- data/examples/v201101/perform_bulk_mutate_job.rb +222 -0
- data/examples/v201101/promote_experiment.rb +88 -0
- data/examples/v201101/set_campaign_targets.rb +111 -0
- data/examples/v201101/update_ad.rb +95 -0
- data/examples/v201101/update_ad_group.rb +90 -0
- data/examples/v201101/update_ad_group_criterion.rb +108 -0
- data/examples/v201101/update_campaign.rb +93 -0
- data/examples/v201101/update_conversion.rb +96 -0
- data/examples/v201101/update_user_list.rb +91 -0
- data/examples/v201101/upload_image.rb +97 -0
- metadata +208 -0
@@ -0,0 +1,93 @@
|
|
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 update a campaign, setting its budget delivery
|
21
|
+
# to 'ACCELERATED'. To create a campaign, run add_campaign.rb.
|
22
|
+
#
|
23
|
+
# Tags: CampaignService.mutate
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
gem 'google-adwords-api'
|
27
|
+
require 'adwords_api'
|
28
|
+
|
29
|
+
API_VERSION = :v201101
|
30
|
+
|
31
|
+
def update_campaign()
|
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
|
+
campaign_srv = adwords.service(:CampaignService, API_VERSION)
|
36
|
+
|
37
|
+
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
38
|
+
|
39
|
+
# Prepare for updating campaign.
|
40
|
+
operation = {
|
41
|
+
:operator => 'SET',
|
42
|
+
:operand => {
|
43
|
+
:id => campaign_id,
|
44
|
+
:budget => {
|
45
|
+
:delivery_method => 'ACCELERATED'
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
# Update campaign.
|
51
|
+
response = campaign_srv.mutate([operation])
|
52
|
+
if response and response[:value]
|
53
|
+
campaign = response[:value].first
|
54
|
+
puts 'Campaign id %d successfully updated, delivery method set to %s.' %
|
55
|
+
[campaign[:id], campaign[:budget][:delivery_method]]
|
56
|
+
else
|
57
|
+
puts 'No campaigns were updated.'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
if __FILE__ == $0
|
62
|
+
# To enable logging of SOAP requests, set the ADWORDSAPI_DEBUG environment
|
63
|
+
# variable to 'true'. This can be done either from your operating system
|
64
|
+
# environment or via code, as done below.
|
65
|
+
ENV['ADWORDSAPI_DEBUG'] = 'false'
|
66
|
+
|
67
|
+
begin
|
68
|
+
update_campaign()
|
69
|
+
|
70
|
+
# Connection error. Likely transitory.
|
71
|
+
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
72
|
+
puts 'Connection Error: %s' % e
|
73
|
+
puts 'Source: %s' % e.backtrace.first
|
74
|
+
|
75
|
+
# API Error.
|
76
|
+
rescue AdwordsApi::Errors::ApiException => e
|
77
|
+
puts 'API Exception caught.'
|
78
|
+
puts 'Message: %s' % e.message
|
79
|
+
puts 'Code: %d' % e.code if e.code
|
80
|
+
puts 'Trigger: %s' % e.trigger if e.trigger
|
81
|
+
puts 'Errors:'
|
82
|
+
if e.errors
|
83
|
+
e.errors.each_with_index do |error, index|
|
84
|
+
puts ' %d. Error type is %s. Fields:' % [index + 1, error[:xsi_type]]
|
85
|
+
error.each_pair do |field, value|
|
86
|
+
if field != :xsi_type
|
87
|
+
puts ' %s: %s' % [field, value]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,96 @@
|
|
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 update a conversion by setting its status to
|
21
|
+
# 'DISABLED'. To get conversions, run get_all_conversions.rb.
|
22
|
+
#
|
23
|
+
# Tags: ConversionTrackerService.mutate
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
gem 'google-adwords-api'
|
27
|
+
require 'adwords_api'
|
28
|
+
|
29
|
+
API_VERSION = :v201101
|
30
|
+
|
31
|
+
def update_conversion()
|
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
|
+
conv_tracker_srv = adwords.service(:ConversionTrackerService, API_VERSION)
|
36
|
+
|
37
|
+
conversion_id = 'INSERT_CONVERSION_ID_HERE'.to_i
|
38
|
+
|
39
|
+
# Prepare for updating conversion.
|
40
|
+
operation = {
|
41
|
+
:operator => 'SET',
|
42
|
+
:operand => {
|
43
|
+
# The 'xsi_type' field allows you to specify the xsi:type of the object
|
44
|
+
# being created. It's only necessary when you must provide an explicit
|
45
|
+
# type that the client library can't infer.
|
46
|
+
:xsi_type => 'AdWordsConversionTracker',
|
47
|
+
:id => conversion_id,
|
48
|
+
:status => 'DISABLED'
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
# Update conversion.
|
53
|
+
response = conv_tracker_srv.mutate([operation])
|
54
|
+
if response and response[:value]
|
55
|
+
conversion = response[:value].first
|
56
|
+
puts "Conversion with id #{conversion[:id]}, name " +
|
57
|
+
"\"#{conversion[:name]}\", status \"#{conversion[:status]}\" and " +
|
58
|
+
" category \"#{conversion[:category]}\" was disabled."
|
59
|
+
else
|
60
|
+
puts 'No conversions were updated.'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
if __FILE__ == $0
|
65
|
+
# To enable logging of SOAP requests, set the ADWORDSAPI_DEBUG environment
|
66
|
+
# variable to 'true'. This can be done either from your operating system
|
67
|
+
# environment or via code, as done below.
|
68
|
+
ENV['ADWORDSAPI_DEBUG'] = 'false'
|
69
|
+
|
70
|
+
begin
|
71
|
+
update_conversion()
|
72
|
+
|
73
|
+
# Connection error. Likely transitory.
|
74
|
+
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
75
|
+
puts 'Connection Error: %s' % e
|
76
|
+
puts 'Source: %s' % e.backtrace.first
|
77
|
+
|
78
|
+
# API Error.
|
79
|
+
rescue AdwordsApi::Errors::ApiException => e
|
80
|
+
puts 'API Exception caught.'
|
81
|
+
puts 'Message: %s' % e.message
|
82
|
+
puts 'Code: %d' % e.code if e.code
|
83
|
+
puts 'Trigger: %s' % e.trigger if e.trigger
|
84
|
+
puts 'Errors:'
|
85
|
+
if e.errors
|
86
|
+
e.errors.each_with_index do |error, index|
|
87
|
+
puts ' %d. Error type is %s. Fields:' % [index + 1, error[:xsi_type]]
|
88
|
+
error.each_pair do |field, value|
|
89
|
+
if field != :xsi_type
|
90
|
+
puts ' %s: %s' % [field, value]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,91 @@
|
|
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 update a user list, setting its description.
|
21
|
+
# To create a user list, run add_user_list.rb.
|
22
|
+
#
|
23
|
+
# Tags: UserListService.mutate
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
gem 'google-adwords-api'
|
27
|
+
require 'adwords_api'
|
28
|
+
|
29
|
+
API_VERSION = :v201101
|
30
|
+
|
31
|
+
def update_user_list()
|
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
|
+
user_list_srv = adwords.service(:UserListService, API_VERSION)
|
36
|
+
|
37
|
+
user_list_id = 'INSERT_USER_LIST_ID_HERE'.to_i
|
38
|
+
|
39
|
+
# Prepare for updating remarketing user list.
|
40
|
+
operation = {
|
41
|
+
:operator => 'SET',
|
42
|
+
:operand => {
|
43
|
+
:id => user_list_id,
|
44
|
+
:description => 'Last updated at %s' % Time.now.to_s
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
# Update user list.
|
49
|
+
response = user_list_srv.mutate([operation])
|
50
|
+
if response and response[:value]
|
51
|
+
user_list = response[:value].first
|
52
|
+
puts 'User list id %d was successfully updated, description set to "%s."' %
|
53
|
+
[user_list[:id], user_list[:description]]
|
54
|
+
else
|
55
|
+
puts 'No user lists were updated.'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
if __FILE__ == $0
|
60
|
+
# To enable logging of SOAP requests, set the ADWORDSAPI_DEBUG environment
|
61
|
+
# variable to 'true'. This can be done either from your operating system
|
62
|
+
# environment or via code, as done below.
|
63
|
+
ENV['ADWORDSAPI_DEBUG'] = 'false'
|
64
|
+
|
65
|
+
begin
|
66
|
+
update_user_list()
|
67
|
+
|
68
|
+
# Connection error. Likely transitory.
|
69
|
+
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
70
|
+
puts 'Connection Error: %s' % e
|
71
|
+
puts 'Source: %s' % e.backtrace.first
|
72
|
+
|
73
|
+
# API Error.
|
74
|
+
rescue AdwordsApi::Errors::ApiException => e
|
75
|
+
puts 'API Exception caught.'
|
76
|
+
puts 'Message: %s' % e.message
|
77
|
+
puts 'Code: %d' % e.code if e.code
|
78
|
+
puts 'Trigger: %s' % e.trigger if e.trigger
|
79
|
+
puts 'Errors:'
|
80
|
+
if e.errors
|
81
|
+
e.errors.each_with_index do |error, index|
|
82
|
+
puts ' %d. Error type is %s. Fields:' % [index + 1, error[:xsi_type]]
|
83
|
+
error.each_pair do |field, value|
|
84
|
+
if field != :xsi_type
|
85
|
+
puts ' %s: %s' % [field, value]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,97 @@
|
|
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 uploads an image. To get images, run get_all_images.rb.
|
21
|
+
#
|
22
|
+
# Tags: MediaService.upload
|
23
|
+
|
24
|
+
require 'rubygems'
|
25
|
+
gem 'google-adwords-api'
|
26
|
+
require 'adwords_api'
|
27
|
+
require 'base64'
|
28
|
+
|
29
|
+
API_VERSION = :v201101
|
30
|
+
|
31
|
+
def upload_image()
|
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
|
+
media_srv = adwords.service(:MediaService, API_VERSION)
|
36
|
+
|
37
|
+
# Create image.
|
38
|
+
image_url = 'https://sandbox.google.com/sandboximages/image.jpg'
|
39
|
+
# This utility method retrieves the contents of a URL using all of the config
|
40
|
+
# options provided to the Api object.
|
41
|
+
image_data = AdsCommon::Http.get(image_url, adwords.config)
|
42
|
+
base64_image_data = Base64.encode64(image_data)
|
43
|
+
image = {
|
44
|
+
# The 'xsi_type' field allows you to specify the xsi:type of the object
|
45
|
+
# being created. It's only necessary when you must provide an explicit
|
46
|
+
# type that the client library can't infer.
|
47
|
+
:xsi_type => 'Image',
|
48
|
+
:data => base64_image_data,
|
49
|
+
:type => 'IMAGE'
|
50
|
+
}
|
51
|
+
|
52
|
+
# Upload image.
|
53
|
+
response = media_srv.upload([image])
|
54
|
+
if response and !response.empty?
|
55
|
+
ret_image = response.first
|
56
|
+
dimensions = AdwordsApi::Utils.map(ret_image[:dimensions])
|
57
|
+
puts "Image with id #{ret_image[:media_id]}, dimensions " +
|
58
|
+
"#{dimensions['FULL'][:height]}x#{dimensions['FULL'][:width]} " +
|
59
|
+
"and MIME type \"#{ret_image[:mime_type]}\" uploaded successfully."
|
60
|
+
else
|
61
|
+
puts "No images uploaded."
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
if __FILE__ == $0
|
66
|
+
# To enable logging of SOAP requests, set the ADWORDSAPI_DEBUG environment
|
67
|
+
# variable to 'true'. This can be done either from your operating system
|
68
|
+
# environment or via code, as done below.
|
69
|
+
ENV['ADWORDSAPI_DEBUG'] = 'false'
|
70
|
+
|
71
|
+
begin
|
72
|
+
upload_image()
|
73
|
+
|
74
|
+
# Connection error. Likely transitory.
|
75
|
+
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
76
|
+
puts 'Connection Error: %s' % e
|
77
|
+
puts 'Source: %s' % e.backtrace.first
|
78
|
+
|
79
|
+
# API Error.
|
80
|
+
rescue AdwordsApi::Errors::ApiException => e
|
81
|
+
puts 'API Exception caught.'
|
82
|
+
puts 'Message: %s' % e.message
|
83
|
+
puts 'Code: %d' % e.code if e.code
|
84
|
+
puts 'Trigger: %s' % e.trigger if e.trigger
|
85
|
+
puts 'Errors:'
|
86
|
+
if e.errors
|
87
|
+
e.errors.each_with_index do |error, index|
|
88
|
+
puts ' %d. Error type is %s. Fields:' % [index + 1, error[:xsi_type]]
|
89
|
+
error.each_pair do |field, value|
|
90
|
+
if field != :xsi_type
|
91
|
+
puts ' %s: %s' % [field, value]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
metadata
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google-adx-buyer-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Danial Klimkin
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-05-24 00:00:00 +04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: google-adwords-api
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 1
|
30
|
+
- 2
|
31
|
+
version: 0.1.2
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
description: google-adx-buyer-api is a DoubleClick Ad Exchange API Buyer API client library for Ruby
|
35
|
+
email: api.dklimkin@gmail.com
|
36
|
+
executables: []
|
37
|
+
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files:
|
41
|
+
- README
|
42
|
+
- COPYING
|
43
|
+
- ChangeLog
|
44
|
+
files:
|
45
|
+
- examples/v201008/add_experiment.rb
|
46
|
+
- examples/v201008/add_ad_group.rb
|
47
|
+
- examples/v201008/add_ad_group_criteria.rb
|
48
|
+
- examples/v201008/add_ads.rb
|
49
|
+
- examples/v201008/add_campaign.rb
|
50
|
+
- examples/v201008/add_placement_performance_report_definition.rb
|
51
|
+
- examples/v201008/add_negative_campaign_criterion.rb
|
52
|
+
- examples/v201008/add_user_list.rb
|
53
|
+
- examples/v201008/check_campaigns.rb
|
54
|
+
- examples/v201008/delete_ad.rb
|
55
|
+
- examples/v201008/delete_ad_group.rb
|
56
|
+
- examples/v201008/delete_ad_group_criterion.rb
|
57
|
+
- examples/v201008/delete_bulk_mutate_job.rb
|
58
|
+
- examples/v201008/delete_campaign.rb
|
59
|
+
- examples/v201008/delete_user_list.rb
|
60
|
+
- examples/v201008/download_report.rb
|
61
|
+
- examples/v201008/get_all_account_changes.rb
|
62
|
+
- examples/v201008/get_all_active_ad_group_criteria.rb
|
63
|
+
- examples/v201008/get_all_ad_group_criteria.rb
|
64
|
+
- examples/v201008/get_all_ad_groups.rb
|
65
|
+
- examples/v201008/get_all_ads.rb
|
66
|
+
- examples/v201008/delete_experiment.rb
|
67
|
+
- examples/v201008/get_all_campaign_targets.rb
|
68
|
+
- examples/v201008/get_all_campaigns.rb
|
69
|
+
- examples/v201008/get_all_disapproved_ads.rb
|
70
|
+
- examples/v201008/get_all_images.rb
|
71
|
+
- examples/v201008/get_all_paused_campaigns.rb
|
72
|
+
- examples/v201008/get_all_report_definitions.rb
|
73
|
+
- examples/v201008/get_all_user_lists.rb
|
74
|
+
- examples/v201008/get_criterion_bid_landscape.rb
|
75
|
+
- examples/v201008/get_geo_location_info.rb
|
76
|
+
- examples/v201008/get_related_placements.rb
|
77
|
+
- examples/v201008/get_report_fields.rb
|
78
|
+
- examples/v201008/get_bulk_mutate_job.rb
|
79
|
+
- examples/v201008/set_campaign_targets.rb
|
80
|
+
- examples/v201008/update_ad.rb
|
81
|
+
- examples/v201008/update_ad_group.rb
|
82
|
+
- examples/v201008/update_ad_group_criterion.rb
|
83
|
+
- examples/v201008/update_campaign.rb
|
84
|
+
- examples/v201008/update_user_list.rb
|
85
|
+
- examples/v201008/upload_image.rb
|
86
|
+
- examples/v201008/get_all_experiments.rb
|
87
|
+
- examples/v201008/perform_bulk_mutate_job.rb
|
88
|
+
- examples/v201008/get_campaign_alerts.rb
|
89
|
+
- examples/v201008/promote_experiment.rb
|
90
|
+
- examples/v201003/add_ad_group.rb
|
91
|
+
- examples/v201003/add_ad_group_criteria.rb
|
92
|
+
- examples/v201003/add_ads.rb
|
93
|
+
- examples/v201003/add_campaign.rb
|
94
|
+
- examples/v201003/add_negative_campaign_criterion.rb
|
95
|
+
- examples/v201003/add_placement_performance_report_definition.rb
|
96
|
+
- examples/v201003/check_campaigns.rb
|
97
|
+
- examples/v201003/delete_ad.rb
|
98
|
+
- examples/v201003/delete_ad_group.rb
|
99
|
+
- examples/v201003/delete_ad_group_criterion.rb
|
100
|
+
- examples/v201003/delete_campaign.rb
|
101
|
+
- examples/v201003/download_report.rb
|
102
|
+
- examples/v201003/get_all_active_ad_group_criteria.rb
|
103
|
+
- examples/v201003/get_all_ad_group_criteria.rb
|
104
|
+
- examples/v201003/get_all_ad_groups.rb
|
105
|
+
- examples/v201003/get_all_ads.rb
|
106
|
+
- examples/v201003/get_all_campaign_targets.rb
|
107
|
+
- examples/v201003/get_all_campaigns.rb
|
108
|
+
- examples/v201003/get_all_disapproved_ads.rb
|
109
|
+
- examples/v201003/get_all_images.rb
|
110
|
+
- examples/v201003/get_all_paused_campaigns.rb
|
111
|
+
- examples/v201003/get_all_report_definitions.rb
|
112
|
+
- examples/v201003/get_criterion_bid_landscape.rb
|
113
|
+
- examples/v201003/get_geo_location_info.rb
|
114
|
+
- examples/v201003/get_related_placements.rb
|
115
|
+
- examples/v201003/get_report_fields.rb
|
116
|
+
- examples/v201003/perform_bulk_mutate_job.rb
|
117
|
+
- examples/v201003/set_campaign_targets.rb
|
118
|
+
- examples/v201003/update_ad.rb
|
119
|
+
- examples/v201003/update_ad_group.rb
|
120
|
+
- examples/v201003/update_ad_group_criterion.rb
|
121
|
+
- examples/v201003/update_campaign.rb
|
122
|
+
- examples/v201003/upload_image.rb
|
123
|
+
- examples/v201101/add_ad_group.rb
|
124
|
+
- examples/v201101/add_ad_group_criteria.rb
|
125
|
+
- examples/v201101/add_ads.rb
|
126
|
+
- examples/v201101/add_campaign.rb
|
127
|
+
- examples/v201101/add_conversion.rb
|
128
|
+
- examples/v201101/add_experiment.rb
|
129
|
+
- examples/v201101/add_negative_campaign_criterion.rb
|
130
|
+
- examples/v201101/add_placement_performance_report_definition.rb
|
131
|
+
- examples/v201101/add_rtb_campaign.rb
|
132
|
+
- examples/v201101/add_user_list.rb
|
133
|
+
- examples/v201101/check_campaigns.rb
|
134
|
+
- examples/v201101/delete_ad.rb
|
135
|
+
- examples/v201101/delete_ad_group.rb
|
136
|
+
- examples/v201101/delete_ad_group_criterion.rb
|
137
|
+
- examples/v201101/delete_bulk_mutate_job.rb
|
138
|
+
- examples/v201101/delete_campaign.rb
|
139
|
+
- examples/v201101/delete_experiment.rb
|
140
|
+
- examples/v201101/delete_user_list.rb
|
141
|
+
- examples/v201101/download_report.rb
|
142
|
+
- examples/v201101/get_ad_group_bid_landscape.rb
|
143
|
+
- examples/v201101/get_all_account_changes.rb
|
144
|
+
- examples/v201101/get_all_active_ad_group_criteria.rb
|
145
|
+
- examples/v201101/get_all_ad_group_criteria.rb
|
146
|
+
- examples/v201101/get_all_ad_groups.rb
|
147
|
+
- examples/v201101/get_all_ads.rb
|
148
|
+
- examples/v201101/get_all_campaign_targets.rb
|
149
|
+
- examples/v201101/get_all_campaigns.rb
|
150
|
+
- examples/v201101/get_all_conversions.rb
|
151
|
+
- examples/v201101/get_all_disapproved_ads.rb
|
152
|
+
- examples/v201101/get_all_experiments.rb
|
153
|
+
- examples/v201101/get_all_images.rb
|
154
|
+
- examples/v201101/get_all_paused_campaigns.rb
|
155
|
+
- examples/v201101/get_all_report_definitions.rb
|
156
|
+
- examples/v201101/get_all_user_lists.rb
|
157
|
+
- examples/v201101/get_bulk_mutate_job.rb
|
158
|
+
- examples/v201101/get_campaign_alerts.rb
|
159
|
+
- examples/v201101/get_criterion_bid_landscape.rb
|
160
|
+
- examples/v201101/get_geo_location_info.rb
|
161
|
+
- examples/v201101/get_related_placements.rb
|
162
|
+
- examples/v201101/get_report_fields.rb
|
163
|
+
- examples/v201101/perform_bulk_mutate_job.rb
|
164
|
+
- examples/v201101/promote_experiment.rb
|
165
|
+
- examples/v201101/set_campaign_targets.rb
|
166
|
+
- examples/v201101/update_ad.rb
|
167
|
+
- examples/v201101/update_ad_group.rb
|
168
|
+
- examples/v201101/update_ad_group_criterion.rb
|
169
|
+
- examples/v201101/update_campaign.rb
|
170
|
+
- examples/v201101/update_conversion.rb
|
171
|
+
- examples/v201101/update_user_list.rb
|
172
|
+
- examples/v201101/upload_image.rb
|
173
|
+
- Rakefile
|
174
|
+
- README
|
175
|
+
- COPYING
|
176
|
+
- ChangeLog
|
177
|
+
has_rdoc: true
|
178
|
+
homepage: http://code.google.com/p/google-api-ads-ruby/
|
179
|
+
licenses: []
|
180
|
+
|
181
|
+
post_install_message:
|
182
|
+
rdoc_options: []
|
183
|
+
|
184
|
+
require_paths:
|
185
|
+
- lib
|
186
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
segments:
|
191
|
+
- 0
|
192
|
+
version: "0"
|
193
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
segments:
|
198
|
+
- 0
|
199
|
+
version: "0"
|
200
|
+
requirements: []
|
201
|
+
|
202
|
+
rubyforge_project:
|
203
|
+
rubygems_version: 1.3.6
|
204
|
+
signing_key:
|
205
|
+
specification_version: 3
|
206
|
+
summary: Ruby Client libraries for DoubleClick Ad Exchange Buyer API
|
207
|
+
test_files: []
|
208
|
+
|