Hi Jeff,
The help you provided in the above reply was quite good. I am now just
trying to generate a report against a particular advertisement. I am
also pasting the code that i am using in generating a report against a
specific report. Can you just have a look at it and let me know that
if its correct? If there is something wrong can you guide me through
by writing some lines of correct code?
Also i have added my comments like ==> in the following code while
creating $report_job xml string.
I would also like to mention here that i am trying to show the advert
report for complete duration from the date it was created. And in
below code i have used some dumy dates.
=============================
$namespace = '
https://sandbox.google.com/api/adwords/v12';
$report_service = SoapClientFactory::GetClient($namespace . '/
ReportService?wsdl', 'wsdl');
$report_service->setHeaders($headers);
$debug = 0;
# Create report job structure.
$report_job =
'<selectedReportType>Creative</selectedReportType>' .
'<name>Sample Keyword Report</name>' .
'<aggregationTypes>Summary</aggregationTypes>' .
'<adWordsType>SearchOnly</adWordsType>' .
'<keywordType>Broad</keywordType>' .
'<startDay>2008-01-01</startDay>' .
'<endDay>2008-12-31</endDay>' .
'<selectedColumns AdId="127650">CreativeId</selectedColumns>' .
==> is this correct way of passing ad id?
'<selectedColumns CampaignId="1786">Campaign</selectedColumns>' .
==> is this correct way of passing campaign id?
'<selectedColumns AdGroupId="5000001207">AdGroup</
selectedColumns>' . ==> is this correct way of passing group id?
'<selectedColumns>Keyword</selectedColumns>' .
'<selectedColumns>KeywordStatus</selectedColumns>' .
'<selectedColumns>KeywordMinCPC</selectedColumns>' .
'<selectedColumns>KeywordDestUrlDisplay</selectedColumns>' .
'<selectedColumns>Impressions</selectedColumns>' .
'<selectedColumns>Clicks</selectedColumns>' .
'<selectedColumns>CTR</selectedColumns>' .
'<selectedColumns>AveragePosition</selectedColumns>';
$request_xml =
'<validateReportJob>' .
'<job xmlns:impl="
https://adwords.google.com/api/adwords/v12" ' .
'xsi:type="impl:DefinedReportJob">' .
$report_job .
'</job>' .
'</validateReportJob>';
# Validate report.
$report_service->call('validateReportJob', $request_xml);
if ($debug) show_xml($report_service);
if ($report_service->fault) show_fault($report_service);
# Schedule report.
$request_xml =
'<scheduleReportJob>' .
'<job xmlns:impl="
https://adwords.google.com/api/adwords/v12" ' .
'xsi:type="impl:DefinedReportJob">' .
$report_job .
'</job>' .
'</scheduleReportJob>';
$job_id = $report_service->call('scheduleReportJob', $request_xml);
$job_id = $job_id['scheduleReportJobReturn'];
if ($debug) show_xml($report_service);
if ($report_service->fault) show_fault($service);
# Wait for report to finish.
$request_xml =
'<getReportJobStatus>' .
'<reportJobId>' .
$job_id .
'</reportJobId>' .
'</getReportJobStatus>';
$status = $report_service->call('getReportJobStatus', $request_xml);
$status = $status['getReportJobStatusReturn'];
if ($debug) show_xml($report_service);
if ($report_service->fault) show_fault($service);
while ($status != 'Completed' and $status != 'Failed') {
//echo 'Report job status is "' . $status . '".' . "\n";
sleep(30);
$status = $report_service->call('getReportJobStatus',
$request_xml);
$status = $status['getReportJobStatusReturn'];
if ($debug) show_xml($report_service);
if ($report_service->fault) show_fault($service);
}
if ($status == 'Failed') {
echo 'Report job generation failed.' . "\n";
return;
}
# Download report.
$request_xml =
'<getReportDownloadUrl>' .
'<reportJobId>' .
$job_id .
'</reportJobId>' .
'</getReportDownloadUrl>';
$report_url = $report_service->call('getReportDownloadUrl',
$request_xml);
$report_url = $report_url['getReportDownloadUrlReturn'];
if ($debug) show_xml($report_service);
if ($report_service->fault) show_fault($service);
=============================
Your quick response will be highly appriciated.
Regards,
Afzaal.
On Nov 7, 9:28 pm, AdWords API Advisor <
adwordsapiadvi...@google.com>
wrote:
> Hello Afzaal,
>
> I think you really need to spend some time familiarizing yourself
> with AdWords reports in general. A good place to start would be to use
> the AdWords web interface to schedule some reports (which will not
> incur any usage fees) and find the right mix of columns and report
> types to get the data you're looking for. Once you have done that, you
> should be able to map the request you made in the AdWords web
> interface into a specific report definition in the AdWords API,
> starting with the selectedReportType:
>
>
http://code.google.com/apis/adwords/docs/developer/DefinedReportJob.h...
>
> and then choosing the corresponding selectedColumns.
>
> If you schedule your report using the AdWords API from the context of
> your MCC account then you can run a cross-client report and get data
> from one or more of the AdWords accounts underneath the MCC at one
> time. See
>
>
http://code.google.com/apis/adwords/docs/developer/adwords_api_servic...