googleads / google-ads-php

Google Ads API Client Library for PHP
https://developers.google.com/google-ads/api/docs/client-libs/php
Apache License 2.0
295 stars 262 forks source link

Not working GAPIC v2 #940

Closed hashimoto-AJ closed 1 year ago

hashimoto-AJ commented 1 year ago

from Google Ads API and AdWords API Forum

My client library and Google Ads API versions:

My environment: PHP version : 8.2.8 Dokcer Desktop(windows11) 5.10.16.3-microsoft-standard-WSL2

Client:
 Cloud integration: v1.0.35
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:53:15 2023
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.21.1 (114176)
 Engine:
  Version:          24.0.2
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       659604f
  Built:            Thu May 25 21:52:17 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Description of the bug: Seeing the notes on this page, I applied this sample code to see how GAPIC v2 works. But I get an error. I tried to get the AdsAPI log, but nothing is output. Please advise the solution.

Regards,

Request/Response Logs:


Fatal error: Uncaught Exception: No such field customerId in /var/www/html/google-ads-php/src/Google/Ads/GoogleAds/V14/Services/GenerateKeywordIdeasRequest.php:150
Stack trace:
#0 /var/www/html/google-ads-php/src/Google/Ads/GoogleAds/V14/Services/GenerateKeywordIdeasRequest.php(150): Google\Protobuf\Internal\Message->__construct(Array)
#1 /var/www/html/google-ads-php/examples/Planning/GenerateKeywordIdeas.php(177): Google\Ads\GoogleAds\V14\Services\GenerateKeywordIdeasRequest->__construct(Array)
#2 /var/www/html/google-ads-php/examples/Planning/GenerateKeywordIdeas.php(90): Google\Ads\GoogleAds\Examples\Planning\GenerateKeywordIdeas::runExample(Object(Google\Ads\GoogleAds\Lib\V14\GoogleAdsClient), {My CustomerID}, Array, 1005, Array, NULL)
#3 /var/www/html/google-ads-php/examples/Planning/GenerateKeywordIdeas.php(209): Google\Ads\GoogleAds\Examples\Planning\GenerateKeywordIdeas::main()
#4 {main}
  thrown in /var/www/html/google-ads-php/src/Google/Ads/GoogleAds/V14/Services/GenerateKeywordIdeasRequest.php on line 150
fiboknacky commented 1 year ago

Could you try changing the key of the array in these lines to be snake case, e.g., customerId -> customer_id, geoTargetConstants -> geo_target_constants?

hashimoto-AJ commented 1 year ago

Is it an error in the sample code?

fiboknacky commented 1 year ago

I think perhaps it's a bug in that particular example. GAPIC generated code sometimes uses both snake cases and camel cases. So, can you run it now?

hashimoto-AJ commented 1 year ago

The problem solved. But, it may not be related to this case, but the following message is output.

Deprecated: Return type of GetOpt\GetOpt::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/google-ads-php/vendor/ulrichsg/getopt-php/src/GetOpt.php on line 583

Deprecated: Return type of GetOpt\GetOpt::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/google-ads-php/vendor/ulrichsg/getopt-php/src/GetOpt.php on line 529

Deprecated: Return type of GetOpt\GetOpt::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/google-ads-php/vendor/ulrichsg/getopt-php/src/GetOpt.php on line 545

Deprecated: Return type of GetOpt\GetOpt::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/google-ads-php/vendor/ulrichsg/getopt-php/src/GetOpt.php on line 561

Deprecated: Return type of GetOpt\GetOpt::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/google-ads-php/vendor/ulrichsg/getopt-php/src/GetOpt.php on line 572

Deprecated: Return type of GetOpt\GetOpt::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/google-ads-php/vendor/ulrichsg/getopt-php/src/GetOpt.php on line 509
fiboknacky commented 1 year ago

It's because of the GetOpt library. You can ignore that.