Jonas Lomholdt Jonas Lomholdt - 1 month ago 11
PHP Question

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

I'm trying to retrieve a report from the AdExchange Seller API.
I am using the maximum allowed amount of dimensions and metrics so the reports is quite big (>100.000 rows). According to the 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. I would prefer to stick to the official Google libraries, but I'm open for suggestions.

Note: adding
alt=csv
or
alt=media
to the
optParams
does not work and I can easily access the data if I remove some of the dimensions and metrics.

More specifically I'm using the
accounts_reports
resource and then the
generate
method. Looking at the source code (shown below), I can't see anywhere that it would be able to accept a
alt
parameter, but I'm obviously missing something.

$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',
),
),
),
)
)
);


Digging further I found this statement in the
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)


But how exactly would that work? As far as I can figure out, it doesn't.

Answer

Not really an answer but to long for a comment.

I don't think you are going to get that to work with the client library. The client libraries are generated via the Discovery Services API. Which gives information about what parameters the API takes. For some reason this alt=csv is not registered in the discovery services for that API. Its there in the description but its not registered as a parameter. So the Client library itself isn't going to build it for you.

You can see the response I am looking at here

An idea would be to make the change to the client library yourself you have the code. While altering the client libraries manually is not ideal it is doable. Try and add alt and give it a value of CSV.

I don't have enough experience with the inner workings of the PHP client library but you can post this as an issue on their forum. Mention that its not in discovery they may have an easer way of applying a random parameter to the query string. I doubt it but its worth a shot.

Comments