สร้างและเข้าถึงรายงานที่ตั้งเวลาไว้

คุณสามารถสร้างและตั้งเวลารายงานโดยใช้เครือข่ายดิสเพลย์ของ Google และ UI ของ Video 360 หรือ API ตัวอย่างเช่น ผู้ใช้ปลายทางจะตั้งค่ารายงานประจำวันที่แสดง หรือรายงานรายเดือนที่แสดงค่าใช้จ่ายทั้งหมด

สร้างรายงานแบบกำหนดเวลา

สร้างรายงานที่ตั้งเวลาไว้ใหม่ในเครือข่ายดิสเพลย์และ อินเทอร์เฟซการรายงาน Video 360 หรือ ด้วยเมธอด API ของ queries.create เปิดรายละเอียดทั้งหมด ดิสเพลย์และ ฟังก์ชันการรายงานของ Video 360 และวิธีสร้างรายงานใหม่มีดังนี้ ที่พบในจอแสดงผลและ เว็บไซต์สนับสนุนของ Video 360

คุณสามารถตั้งเวลารายงานขณะสร้างโดยใช้ช่อง Repeats ใน UI และ schedule ใน API ควรตั้งค่าฟิลด์เหล่านี้เป็น ช่วงเวลาที่เหมาะสม

หลังจากตั้งค่าฟิลด์ที่เหมาะสมแล้ว รายงานนี้จะทํางานตามกําหนดเวลาดังกล่าวและ รายงานที่สร้างขึ้นจะมีให้ดาวน์โหลด

เข้าถึงรายงานที่ตั้งเวลาไว้

รายงานที่ตั้งเวลาไว้จะสร้างขึ้นเป็นไฟล์ CSV แบบง่ายและจัดเก็บไว้โดยอัตโนมัติ และปลอดภัยใน Google Cloud Storage อย่างไรก็ตาม คุณไม่สามารถเข้าถึง ที่เก็บข้อมูล Google Cloud Storage ที่มีไฟล์เหล่านี้โดยตรง แต่ สามารถดาวน์โหลดไฟล์ด้วยตัวเองได้จาก จอแสดงผลและ UI ของวิดีโอ 360 หรือดึงข้อมูล เขียนโปรแกรมโดยใช้ URL ที่ได้รับอนุญาตล่วงหน้าที่ได้รับจาก API

ด้านล่างนี้คือตัวอย่างการใช้ API เพื่อดาวน์โหลดไฟล์รายงาน ด้วยวิธีนี้ ตัวอย่างเช่น queries.reports.list ใช้กับตัวเลือก orderBy เพื่อดึงข้อมูลรายงานล่าสุด ภายใต้ข้อความค้นหา จากนั้น ช่อง Report.reportMetadata.googleCloudStoragePath คือ ซึ่งใช้เพื่อค้นหาไฟล์รายงานและดาวน์โหลดเนื้อหาลงในไฟล์ CSV ในเครื่อง

Java

การนำเข้าที่จำเป็น:

import com.google.api.client.googleapis.media.MediaHttpDownloader;
import com.google.api.client.googleapis.util.Utils;
import com.google.api.client.http.GenericUrl;
import com.google.api.services.doubleclickbidmanager.DoubleClickBidManager;
import com.google.api.services.doubleclickbidmanager.model.ListReportsResponse;
import com.google.api.services.doubleclickbidmanager.model.Report;
import java.io.FileOutputStream;
import java.io.OutputStream;

ตัวอย่างโค้ด

long queryId = query-id;

// Call the API, listing the reports under the given queryId from most to
// least recent.
ListReportsResponse reportListResponse =
    service
        .queries()
        .reports()
        .list(queryId)
        .setOrderBy("key.reportId desc")
        .execute();

// Iterate over returned reports, stopping once finding a report that
// finished generating successfully.
Report mostRecentReport = null;
if (reportListResponse.getReports() != null) {
  for (Report report : reportListResponse.getReports()) {
    if (report.getMetadata().getStatus().getState().equals("DONE")) {
      mostRecentReport = report;
      break;
    }
  }
} else {
  System.out.format("No reports exist for query Id %s.\n", queryId);
}

// Download report file of most recent finished report found.
if (mostRecentReport != null) {
  // Retrieve GCS URL from report object.
  GenericUrl reportUrl =
      new GenericUrl(mostRecentReport.getMetadata().getGoogleCloudStoragePath());

  // Build filename.
  String filename =
      mostRecentReport.getKey().getQueryId() + "_"
          + mostRecentReport.getKey().getReportId() + ".csv";

  // Download the report file.
  try (OutputStream output = new FileOutputStream(filename)) {
    MediaHttpDownloader downloader =
        new MediaHttpDownloader(Utils.getDefaultTransport(), null);
    downloader.download(reportUrl, output);
  }
  System.out.format("Download of file %s complete.\n", filename);
} else {
  System.out.format(
      "There are no completed report files to download for query Id %s.\n",
      queryId);
}

Python

การนำเข้าที่จำเป็น:

from contextlib import closing
from six.moves.urllib.request import urlopen

ตัวอย่างโค้ด

query_id = query-id

# Call the API, listing the reports under the given queryId from most to
# least recent.
response = service.queries().reports().list(queryId=query_id, orderBy="key.reportId desc").execute()

# Iterate over returned reports, stopping once finding a report that
# finished generating successfully.
most_recent_report = None
if response['reports']:
  for report in response['reports']:
    if report['metadata']['status']['state'] == 'DONE':
      most_recent_report = report
      break
else:
  print('No reports exist for query Id %s.' % query_id)

# Download report file of most recent finished report found.
if most_recent_report != None:
  # Retrieve GCS URL from report object.
  report_url = most_recent_report['metadata']['googleCloudStoragePath']

  # Build filename.
  output_file = '%s_%s.csv' % (report['key']['queryId'], report['key']['reportId'])

  # Download the report file.
  with open(output_file, 'wb') as output:
    with closing(urlopen(report_url)) as url:
      output.write(url.read())
  print('Download of file %s complete.' % output_file)
else:
  print('There are no completed report files to download for query Id %s.' % query_id)

PHP

$queryId = query-id;

// Call the API, listing the reports under the given queryId from most to
// least recent.
$optParams = array('orderBy' => "key.reportId desc");
$response = $service->queries_reports->listQueriesReports($queryId, $optParams);

// Iterate over returned reports, stopping once finding a report that
// finished generating successfully.
$mostRecentReport = null;
if (!empty($response->getReports())) {
  foreach ($response->getReports() as $report) {
    if ($report->metadata->status->state == "DONE") {
      $mostRecentReport = $report;
      break;
    }
  }
} else {
  printf('<p>No reports exist for query ID %s.</p>', $queryId);
}

// Download report file of most recent finished report found.
if ($mostRecentReport != null) {
  // Build filename.
  $filename = $mostRecentReport->key->queryId . '_' . $mostRecentReport->key->reportId . '.csv';

  // Download the report file.
  file_put_contents($filename, fopen($mostRecentReport->metadata->googleCloudStoragePath, 'r'));
  printf('<p>Download of file %s complete.</p>', $filename);
} else {
  printf('<p>There are no completed report files to download for query Id %s.</p>', $queryId);
}