campaign_ids = []
for campaign in campaigns[0]['entries']:
  # We only care about active campaigns.
  if campaign['status'] not in ('DELETED', 'PAUSED'):
    campaign_ids.append(campaign['id'])
print 'Campaign ids: %s' % campaign_ids

# Construct report job.
job = {
    'aggregationTypes': ['Summary'],
    'campaigns': campaign_ids,
    'endDay': '2009-01-31',
    'name': 'Test Campaign Report',
    'selectedColumns': ['Campaign', 'CampaignId', 'CPC', 'CTR'],
    'selectedReportType': 'Campaign',
    'startDay': '2009-01-01',
}

# Schedule report and get back report job id.
print 'Scheduling report job using v13...'
report_service = client.GetReportService('https://sandbox.google.com', 'v13')
job_id = report_service.ScheduleDefinedReportJob(job)[0]
print 'Report job id is \'%s\'.' % job_id

print 'Downloading report using v13...'
print report_service.DownloadXmlReport(job_id)

print
print ('Usage: %s units, %s operations' % (client.GetUnits(),
                                           client.GetOperations()))
예제 #2
0
        'xmlns:impl',
        ('https://adwords.google.com/api/adwords/%s' % MIN_API_VERSION))
    job._setAttr('xsi:type', 'impl:DefinedReportJob')

    # Schedule report and get back report's job id.
    job_id = client.CallMethod(
        ('https://sandbox.google.com/api/adwords/%s/ReportService' %
         MIN_API_VERSION), 'scheduleReportJob', (job), None)[0]
    print 'Report job Id is \'%s\'' % job_id

# Option 2: Schedule report job while using library's validation logic.
#
# Construct report job.
job = {
    'aggregationTypes': ['Summary'],
    'endDay': '2009-01-31',
    'name': 'Test Campaign Report',
    'selectedColumns': ['Campaign', 'CampaignId', 'CPC', 'CTR'],
    'selectedReportType': 'Campaign',
    'startDay': '2009-01-01',
}

# Schedule report and get back report job id.
job_id = client.GetReportService('https://sandbox.google.com',
                                 'v13').ScheduleDefinedReportJob(job)[0]
print 'Report job Id is \'%s\'' % job_id

print
print('Usage: %s units, %s operations' %
      (client.GetUnits(), client.GetOperations()))