function getreportdata($reportId, $username, $authToken, $applicationName) {
// Set SOAP and XML settings. Since there is no Report Central on the test
// environment, reporting examples work against the production environment.
$reportWsdl = 'https://advertisersapi.doubleclick.net/v1.20/api/' .
'dfa-api/report?wsdl';
$namespace = 'http://www.doubleclick.net/dfa-api/v1.20';
$options = array('encoding' => 'utf-8');
// Get ReportService.
$reportService = new SoapClient($reportWsdl, $options);
// Set headers.
$headers = array(DfaHeadersUtil::createWsseHeader($username, $authToken),
DfaHeadersUtil::createRequestHeader($namespace, $applicationName));
$reportService->__setSoapHeaders($headers);
print_r($headers);
// Create report request object.
$reportRequest = array(
'queryId' => 0,
'reportId' => $reportId);
try {
// Get report information.
$result = $reportService->getReport($reportRequest);
} catch (Exception $e) {
print $e->getMessage();
exit(1);
}
return $result;
}
Thanks,
B.
require_once 'DfaHeadersUtil.php';
// Provide DFA login information.
$username = 'myusername';
$password = 'mypassword';
$applicationName = 'DFA';
// Set SOAP and XML settings. To send requests to the production environment,
// replace "advertisersapitest.doubleclick.net" with
// "advertisersapi.doubleclick.net" in the wsdl URL. The namespace will always
// be "www.doubleclick.net", even in the test environment.
$loginWsdl = 'https://advertisersapi.doubleclick.net/v1.20/api/' .
'dfa-api/login?wsdl';
// Get LoginService.
$loginService = new SoapClient($loginWsdl, $options);
// Set header.
$header = DfaHeadersUtil::createRequestHeader($namespace, $applicationName);
$loginService->__setSoapHeaders($header);
try {
// Authenticate.
$result = $loginService->authenticate($username, $password);
} catch (Exception $e) {
print $e->getMessage();
exit(1);
}
// Display user profile token, DFA account name and network ID.
print "User profile token is \"" . $result->token
. "\", DFA account name is \"" . $result->networkName
. "\", and DFA account ID is \"" . $result->networkId . "\".";
Getreport.php:
require_once 'DfaHeadersUtil.php';
// Provide criteria to search upon.
$reportId = (float) 'myreportid';
// Provide information required for DFA headers.
$username = 'myusername';
$authToken = 'token_returned_from_authenticate.php';
$applicationName = 'DFA';
// Set SOAP and XML settings. Since there is no Report Central on the test
// environment, reporting examples work against the production environment.
$reportWsdl = 'https://advertisersapi.doubleclick.net/v1.20/api/' .
'dfa-api/report?wsdl';
$namespace = 'http://www.doubleclick.net/dfa-api/v1.20';
$options = array('encoding' => 'utf-8');
// Get ReportService.
$reportService = new SoapClient($reportWsdl, $options);
// Set headers.
$headers = array(DfaHeadersUtil::createWsseHeader($username, $authToken),
DfaHeadersUtil::createRequestHeader($namespace, $applicationName));
$reportService->__setSoapHeaders($headers);
// Create report request object.
$reportRequest = array(
'queryId' => 0,
'reportId' => $reportId);
try {
// Get report information.
$result = $reportService->getReport($reportRequest);
} catch (Exception $e) {
print $e->getMessage();
exit(1);
}
// Display report status and download URL. The URL will be blank if the report
// is not done.
print 'This report\'s status is "' . $result->status->name . '" and URL is "'
. $result->url . '".\n';