BingAds 报告

BingAds Reports

提问人:Roza Adamyan 提问时间:7/11/2023 更新时间:7/11/2023 访问量:101

问:

**有没有办法在不下载文件的情况下从报告请求中获取数据?** 我目前正在使用 Bing API 通过 CampaignPerformancReportRequest 类获取广告系列绩效报告。我想获取数据并使用它来显示一些指标。我的应用程序的负载非常高。用户数量为数百万,因此加载每个用户的所有数据然后从文件中读取将非常慢。谁能帮忙? 这是我目前正在使用的代码,但我确实希望找到一些方法来摆脱读取/下载文件。

        var reportRequest = new CampaignPerformanceReportRequest {
            ReportName = "CampaignPerformanceReport",
            ExcludeColumnHeaders = false,
            ExcludeReportFooter = true,
            ExcludeReportHeader = false,
            Format = ReportFormat.Csv,
            Aggregation = ReportAggregation.Daily,
            ReturnOnlyCompleteData = false,
            Columns = new[]
            {
                CampaignPerformanceReportColumn.CampaignId,
                CampaignPerformanceReportColumn.CampaignName,
                CampaignPerformanceReportColumn.CampaignType, 
                CampaignPerformanceReportColumn.CampaignStatus,
                CampaignPerformanceReportColumn.Impressions,
                CampaignPerformanceReportColumn.TimePeriod
                  
            },
            Scope = new AccountThroughCampaignReportScope {
                AccountIds = new List<long>() { 11, 22},
            },
            Filter = new CampaignPerformanceReportFilter() {
                Status = CampaignStatusReportFilter.Active | CampaignStatusReportFilter.Paused | CampaignStatusReportFilter.BudgetPaused | CampaignStatusReportFilter.Suspended
            },
            Time = new ReportTime {
                CustomDateRangeStart = new Microsoft.BingAds.V13.Reporting.Date() { Day = 10, Month = 7, Year = 2020 },
                CustomDateRangeEnd = new Microsoft.BingAds.V13.Reporting.Date() { Day = 9, Month = 7, Year = 2023 },          
                ReportTimeZone = ReportTimeZone.EasternTimeUSCanada
            }
        };

        var reportingDownloadParameters = new ReportingDownloadParameters {
            ReportRequest = reportRequest,
            ResultFileName = "n12t",
            OverwriteResultFile = true,
        };

        Report reportContainer = (await reportingServiceManager.DownloadReportAsync(
                  parameters: reportingDownloadParameters,
                  cancellationToken: CancellationToken.None));

        long recordCount = reportContainer.ReportRecordCount;
        IEnumerable<IReportRecord> reportRecordIterable = reportContainer.GetReportRecords();
        int totalImpressions = 0;
        foreach (IReportRecord record in reportContainer.GetReportRecords()) {
            totalImpressions += record.GetIntegerValue("Impressions");
        }

        reportContainer.Dispose();
        reportingServiceManager.CleanupTempFiles();

我正在尝试找到一种在大量用户的情况下处理 Bing Ads api 报告的好方法

广告 Bing Bing-Ads-API

评论


答: 暂无答案