ReportUtils::DownloadReportWithAwql PHP Метод

DownloadReportWithAwql() публичный Метод

Downloads a report with AWQL. If the path parameter is specified it will be downloaded to the file at that path, otherwise it will be downloaded to memory and be returned as a string.
public DownloadReportWithAwql ( string $reportQuery, string $path = null, AdWordsUser $user, $reportFormat, array $options = null ) : mixed
$reportQuery string the query to use for the report
$path string an optional path of the file to download the report to
$user AdWordsUser the user to retrieve report with
$options array the option to use when downloading the report: {string} server: the server to make the request to. If null, then the default server will be used {string} version: the version to make the request against. If null, then the default version will be used
Результат mixed if path isn't specified the contents of the report, otherwise the size in bytes of the downloaded report
    public function DownloadReportWithAwql($reportQuery, $path = null, AdWordsUser $user, $reportFormat, array $options = null)
    {
        if ($path === null || $path === '') {
            $this->adsUtilityRegistry->addUtility(AdsUtility::REPORT_UTILS_STRING);
        } else {
            $this->adsUtilityRegistry->addUtility(AdsUtility::REPORT_UTILS_FILE);
        }
        return ReportUtilsDelegate::DownloadReportWithAwql($reportQuery, $path, $user, $reportFormat, $options);
    }

Same methods

ReportUtils::DownloadReportWithAwql ( string $reportQuery, string $path = null, AdWordsUser $user, $reportFormat, array $options = null, array $customCurlOptions = null ) : mixed

Usage Example

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $filePath the path of the file to download the report to
 */
function DownloadCriteriaReportWithAwqlExample(AdWordsUser $user, $filePath, $reportFormat)
{
    // Optional: Set clientCustomerId to get reports of your child accounts
    // $user->SetClientCustomerId('INSERT_CLIENT_CUSTOMER_ID_HERE');
    // Prepare a date range for the last week. Instead you can use 'LAST_7_DAYS'.
    $dateRange = sprintf('%d,%d', date('Ymd', strtotime('-7 day')), date('Ymd', strtotime('-1 day')));
    // Create report query.
    $reportQuery = 'SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, ' . 'Impressions, Clicks, Cost FROM CRITERIA_PERFORMANCE_REPORT ' . 'WHERE Status IN [ENABLED, PAUSED] DURING ' . $dateRange;
    // Set additional options.
    $options = array('version' => ADWORDS_VERSION);
    // Optional: Set skipReportHeader, skipColumnHeader, skipReportSummary to
    //     suppress headers or summary rows.
    // $options['skipReportHeader'] = true;
    // $options['skipColumnHeader'] = true;
    // $options['skipReportSummary'] = true;
    //
    // Optional: Set useRawEnumValues to return enum values instead of enum
    //     display values.
    // $options['useRawEnumValues'] = false;
    //
    // Optional: Set includeZeroImpressions to include zero impression rows in
    //     the report output.
    // $options['includeZeroImpressions'] = true;
    // Download report.
    $reportUtils = new ReportUtils();
    $reportUtils->DownloadReportWithAwql($reportQuery, $filePath, $user, $reportFormat, $options);
    printf("Report was downloaded to '%s'.\n", $filePath);
}
All Usage Examples Of ReportUtils::DownloadReportWithAwql