google-ads-php
google-ads-php copied to clipboard
Invalid Argument
Hello, I did several queries with the same query. the following query i did
SELECT ad_group_ad.ad.final_urls,ad_group_ad.status, metrics.cost_micros FROM ad_group_ad WHERE segments.date >= '2022-07-01' AND segments.date <= '2022-07-31' and ad_group_ad.status = 'ENABLED' ORDER BY metrics.cost_micros
I made several requests with the query listed above. the query is successful and sometimes the query has an error
======================================================================== error displayed
An uncaught Exception was encountered Type: Google\Ads\GoogleAds\Lib\V8\GoogleAdsException
Message: { "message": "Request contains an invalid argument.", "code": 3, "status": "INVALID_ARGUMENT", "details": [ { "@type": "google.ads.googleads.v8.errors.googleadsfailure-bin", "data": "" }, { "@type": "grpc-status-details-bin", "data": "" }, { "@type": "request-id", "data": "AXY5aYwfbxFuO9fsplQS7w" } ] }
Filename: /mnt/data/home/538683.cloudwaysapps.com/zychgrwtef/public_html/cart/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V8/GoogleAdsExceptionTrait.php
Line Number: 75
Backtrace:
File: /mnt/data/home/538683.cloudwaysapps.com/zychgrwtef/public_html/cart/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V8/GoogleAdsExceptionTrait.php Line: 50 Function: createGoogleAdsException
File: /mnt/data/home/538683.cloudwaysapps.com/zychgrwtef/public_html/cart/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V8/ServerStreamingGoogleAdsExceptionMiddleware.php Line: 97 Function: throwGoogleAdsException
File: /mnt/data/home/538683.cloudwaysapps.com/zychgrwtef/public_html/cart/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V8/ServerStreamingGoogleAdsResponseMetadataCallable.php Line: 75 Function: readAll
end code
===================================================================== and this is my code
protected function get_gads_cost_for_test(GoogleAdsClient $googleAdsClient, int $customerId, string $source, $startDate, $endDate) { $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
$query = "SELECT ad_group_ad.ad.final_urls,ad_group_ad.status, metrics.cost_micros FROM ad_group_ad WHERE segments.date >= '$startDate' AND segments.date <= '$endDate' and ad_group_ad.status = 'ENABLED' ORDER BY metrics.cost_micros";
$stream = $googleAdsServiceClient->searchStream($customerId, $query);
$totalAds = 0;
foreach ($stream->iterateAllElements() as $googleAdsRow) {
foreach($googleAdsRow->getAdGroupAd()->getAd()->getFinalUrls() as $finalUrlRow) {
if (preg_match("/sumber=$source\b/i", $finalUrlRow)){
$totalAds += $googleAdsRow->getMetrics()->getCostMicros() / 1000000;
}
}
}
return $totalAds;
}
=============================================================================== end code
can you help me why the API is unstable so sometimes it works and sometimes it error.
v8 is already sunset. Could you please upgrade to the latest version and try again?
Closing due to inactivity. Feel free to reopen this if you still face the issue.