OiO.lk Blog PHP Google ads API PHP cannot run the documentation example
PHP

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)!!1

The requested URL /v14/customers/vvvv/googleAds:searchStream was not found on this server. That’s all we know.

Any help would be very much appreciated



You need to sign in to view this answers

Exit mobile version