Update AdExchange Buyer API examples to version v1.2.

Fixes issue #248.
This commit is contained in:
Joe Gregorio
2013-03-18 09:15:57 -04:00
parent 73c9a44df0
commit 731680a341
3 changed files with 11 additions and 17 deletions

View File

@@ -19,7 +19,8 @@
Tags: creatives.insert
"""
__author__ = 'david.t@google.com (David Torres)'
__author__ = ('david.t@google.com (David Torres)',
'jdilallo@google.com (Joseph DiLallo)')
import pprint
import sys
@@ -32,11 +33,6 @@ gflags.DEFINE_string('account_id', None,
'The ID of the account that contains the creative',
short_name='a')
gflags.MarkFlagAsRequired('account_id')
gflags.DEFINE_string('adgroup_id', None,
'The pretargeting adgroup id to which the creative is '
'associated with',
short_name='g')
gflags.MarkFlagAsRequired('adgroup_id')
gflags.DEFINE_string('buyer_creative_id', None,
'A buyer-specific id that identifies this creative',
short_name='c')
@@ -46,7 +42,6 @@ gflags.MarkFlagAsRequired('buyer_creative_id')
def main(argv):
sample_utils.process_flags(argv)
account_id = gflags.FLAGS.account_id
adgroup_id = gflags.FLAGS.adgroup_id
buyer_creative_id = gflags.FLAGS.buyer_creative_id
pretty_printer = pprint.PrettyPrinter()
@@ -56,7 +51,6 @@ def main(argv):
try:
# Construct the request.
request = service.creatives().get(accountId=account_id,
adgroupId=adgroup_id,
buyerCreativeId=buyer_creative_id)
# Execute request and print response.

View File

@@ -108,5 +108,5 @@ def initialize_service():
http = credentials.authorize(http)
# Construct a service object via the discovery service.
service = build('adexchangebuyer', 'v1', http=http)
service = build('adexchangebuyer', 'v1.2', http=http)
return service

View File

@@ -19,7 +19,8 @@
Tags: creatives.insert
"""
__author__ = 'david.t@google.com (David Torres)'
__author__ = ('david.t@google.com (David Torres)',
'jdilallo@google.com (Joseph DiLallo)')
import pprint
import sys
@@ -32,22 +33,20 @@ gflags.DEFINE_string('account_id', None,
'The ID of the account to which submit the creative',
short_name='a')
gflags.MarkFlagAsRequired('account_id')
gflags.DEFINE_string('adgroup_id', None,
'The pretargeting adgroup id that this creative will be '
'associated with',
short_name='g')
gflags.MarkFlagAsRequired('adgroup_id')
gflags.DEFINE_string('buyer_creative_id', None,
'A buyer-specific id identifying the creative in this ad',
short_name='c')
gflags.MarkFlagAsRequired('buyer_creative_id')
gflags.DEFINE_string('agency_id', None,
'The id of the agency who created this ad',
short_name='g')
def main(argv):
sample_utils.process_flags(argv)
account_id = gflags.FLAGS.account_id
adgroup_id = gflags.FLAGS.adgroup_id
buyer_creative_id = gflags.FLAGS.buyer_creative_id
agency_id = gflags.FLAGS.agency_id
pretty_printer = pprint.PrettyPrinter()
# Authenticate and construct service.
@@ -57,7 +56,6 @@ def main(argv):
# Create a new creative to submit.
creative_body = {
'accountId': account_id,
'adgroupId': adgroup_id,
'buyerCreativeId': buyer_creative_id,
'HTMLSnippet': ('<html><body><a href="http://www.google.com">'
'Hi there!</a></body></html>'),
@@ -66,6 +64,8 @@ def main(argv):
'height': 250,
'advertiserName': 'google'
}
if agency_id:
creative_body['agencyId'] = agency_id
creative = service.creatives().insert(body=creative_body).execute()
# Print the response. If the creative has been already reviewed, its status
# and categories will be included in the response.