Closed PsychodelEKS closed 6 years ago
Played around with this myself - the problem is with
`Google_Http_Request::toBatchString (Http/Request.php)
it uses http_build_query
to rebuild url with query string for report and breaks the url, because some parameters which are specified as arrays must not be treated as array when building url, i.e.:
$params = array(
'metrics' => array('metr_1', 'metr_2'),
'dimensions' => array('dim_1', 'dim_2'),
)
are converted to:
metric%5B0%5D=metr_1&metric%5B1%5D=metr_2&dimensions%5B0%5D=dim_1&dimensions%5B1%5D=dim_2
and must be:
metric=metr_1&metric=metr_2&dimensions=dim_1&dimensions=dim_2
that is handled correctly for non-batch requests with Google_Http_REST::createRequestUri
,
but this method uses modified parameters array which is not stored for later usage in request itself
the easy way to fix this seems to use prebuilt url from the request and to remove server addr from it:
$path = str_replace('https://www.googleapis.com', '', $this->getUrl());
but not sure if totally conforms all the requirements (works fine for me)
$path = preg_replace('/(dimension|metric)%5B\d+?%5D/im', '$1', $path);
is more fool-proof, but still not of production quality
@PsychodelEKS Is this still an issue for you? I still haven't looked at the v1 branch at all.
@mattwhisenhunt I did not actually update the lib since the issue was created, so dunno if it was fixed or not. Since Google seems to migrate to DFP API now, we've moved to it from this one, so for me - not an issue anymore =)
I'm trying to use batch requests to retreive reports data from AdExchange account, but it does not seem to work as expected:
simple call version works fine (abstract code):
$reportData = $Service->accounts_reports->generate($googleAccountId, $startDate, $endDate, $optParams);
but using batch it fails:
with:
generate
method correctly returnsGoogle_Http_Request
object when called aftersetUseBatch(true)
, all report params are set correctly according to it's dump.Is that me doing smth wrong, or is it broken, or not supported on server side?