从 AdExchange 卖家生成报告时添加 `alt` 参数 API

Add `alt` parameter while generating reports from AdExchange Seller API

我正在尝试从 AdExchange Seller API 检索报告。 我使用了最大允许量的维度和指标,因此报告非常大(>100.000 行)。根据documentation on large reports this is possible using the limit break feature by adding the alt=media parameter. But I can't figure out how to add that parameter using the Google API client for PHP。我宁愿坚持使用官方 Google 库,但我愿意接受建议。

注意:将 alt=csvalt=media 添加到 optParams 不起作用,如果我删除一些维度和指标,我可以轻松访问数据。

更具体地说,我使用了 accounts_reports 资源,然后是 generate 方法。查看源代码(如下所示),我看不到它可以接受 alt 参数的任何地方,但我显然遗漏了一些东西。

$this->accounts_reports = new Google_Service_AdExchangeSeller_Resource_AccountsReports(
        $this,
        $this->serviceName,
        'reports',
        array(
          'methods' => array(
            'generate' => array(
              'path' => 'accounts/{accountId}/reports',
              'httpMethod' => 'GET',
              'parameters' => array(
                'accountId' => array(
                  'location' => 'path',
                  'type' => 'string',
                  'required' => true,
                ),
                'startDate' => array(
                  'location' => 'query',
                  'type' => 'string',
                  'required' => true,
                ),
                'endDate' => array(
                  'location' => 'query',
                  'type' => 'string',
                  'required' => true,
                ),
                'dimension' => array(
                  'location' => 'query',
                  'type' => 'string',
                  'repeated' => true,
                ),
                'filter' => array(
                  'location' => 'query',
                  'type' => 'string',
                  'repeated' => true,
                ),
                'locale' => array(
                  'location' => 'query',
                  'type' => 'string',
                ),
                'maxResults' => array(
                  'location' => 'query',
                  'type' => 'integer',
                ),
                'metric' => array(
                  'location' => 'query',
                  'type' => 'string',
                  'repeated' => true,
                ),
                'sort' => array(
                  'location' => 'query',
                  'type' => 'string',
                  'repeated' => true,
                ),
                'startIndex' => array(
                  'location' => 'query',
                  'type' => 'integer',
                ),
              ),
            ),
          )
        )
    );

进一步挖掘,我在 Google_Service_AdExchangeSeller_Resource_AccountsReports class.

中找到了这条语句

Generate an Ad Exchange report based on the report request sent in the query parameters. Returns the result as JSON; to retrieve output in CSV format specify "alt=csv" as a query parameter. (reports.generate)

但这究竟是如何运作的呢?据我所知,事实并非如此。

不是真正的答案,而是渴望发表评论。

我认为您不会让它与客户端库一起使用。客户端库是通过发现服务 API 生成的。其中提供了有关 API 采用哪些参数的信息。由于某种原因,此 alt=csv 未在 API 的发现服务中注册。它在描述中,但未注册为参数。所以客户端库本身不会为你构建它。

你可以看到我正在看的回复here

如果您有代码,可以自己更改客户端库。虽然手动更改客户端库并不理想,但它是可行的。 尝试添加 alt 并为其赋予 CSV 值。

我对 PHP 客户端库的内部运作没有足够的经验,但您可以 post 在他们的论坛上将其作为 issue。提到它不是在发现中,他们可能有一种更简单的方法将随机参数应用于查询字符串。我对此表示怀疑,但值得一试。

PHP 客户端库应该可以做到这一点。以下示例演示了如何使用驱动器 API:

$fileId = '0BwwA4oUTeiV1UVNwOHItT0xfa2M';
$content = $driveService->files->get($fileId, array(
  'alt' => 'media' ));

https://developers.google.com/drive/v3/web/manage-downloads#examples