import sys sys.path.append('../..') # Import appropriate classes from the client library. from aw_api.Client import Client # Initialize client object. client = Client(path='../..') # Initialize appropriate service. campaign_service = client.GetCampaignService( 'https://adwords-sandbox.google.com', 'v200909') # Construct selector and get all paused campaigns. selector = {'campaignStatuses': ['PAUSED']} campaigns = campaign_service.Get(selector)[0] # Display results. if 'entries' in campaigns: for campaign in campaigns['entries']: print( 'Campaign with id \'%s\', name \'%s\', and status \'%s\' was found.' % (campaign['id'], campaign['name'], campaign['status'])) else: print 'No campaigns were found.' print print('Usage: %s units, %s operations' % (client.GetUnits(), client.GetOperations()))
} geo_location = geo_location_service.Get(selector)[0] # Construct operations and add ad extension override. operations = [ { 'operator': 'ADD', 'operand': { 'adId': ad_id, 'adExtension': { 'type': 'LocationExtension', 'id': ad_extension_id, 'address': geo_location['address'], 'geoPoint': geo_location['geoPoint'], 'encodedLocation': geo_location['encodedLocation'], 'source': 'ADWORDS_FRONTEND' } } } ] ad_extensions = ad_extension_override_service.Mutate(operations)[0] # Display results. for ad_extension in ad_extensions['value']: print ('Ad extension override with id \'%s\' for ad with id \'%s\' was added.' % (ad_extension['adExtension']['id'], ad_extension['adId'])) print print ('Usage: %s units, %s operations' % (client.GetUnits(), client.GetOperations()))