Google ads API PHP cannot run the documentation example
I'm running symfony 6 server / php 8.0.8, google ads api V22.0.0. Got dev token/refresh token, and all other infos, and annot run simple example from google and I'm not sure what I'm doing wrong. Here is my code:
use Google\Ads\GoogleAds\Lib\V14\GoogleAdsClientBuilder; use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder; use Google\Ads\GoogleAds\V14\Services\GoogleAdsServiceClient; use Google\Ads\GoogleAds\V14\Services\SearchGoogleAdsStreamRequest; $developerToken = 'xxxx'; $clientId = 'yyyy'; $clientSecret = 'zzzz'; $refreshToken = 'dddd'; $loginCustomerId = 'vvvv'; try { $oAuth2Credential = (new OAuth2TokenBuilder()) ->withClientId($clientId) ->withClientSecret($clientSecret) ->withRefreshToken($refreshToken) ->build(); $googleAdsClient = (new GoogleAdsClientBuilder()) ->withDeveloperToken($developerToken) ->withOAuth2Credential($oAuth2Credential) ->withLoginCustomerId($loginCustomerId) ->build(); $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient(); $query = 'SELECT campaign.id, campaign.name FROM campaign ORDER BY campaign.id'; $stream2 = $googleAdsServiceClient->searchStream($loginCustomerId, $query ); foreach ($stream2->iterateAllElements() as $googleAdsRow) { not reaching this } } catch (\Google\ApiCore\ApiException $e) { // Gérer les erreurs $this->_logCall(self::LOG_GOOGLE_ADS, 'ERREUR:',$e->getBasicMessage()); }
And here is the error:
Error 404 (Not Found)!!1The requested URL
/v14/customers/vvvv/googleAds:searchStream
was not found on this server. That’s all we know.
Using V14 was not OK, I was able to update google ads api from 22.0.0 to 22.1.0, doing this gave me access to V16. After what only issue was to use MCC id to instanciate googleAdsClient and then using client id to instanciate searchStream