Posts tagged with symfony

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.

I want to return the result printed , to use in other function.

Here is the code:

"Keyword idea text '%s' has %d average monthly searches and competition as %d.%s", $result->getText()->getValue(), is_null($result->getKeywordIdeaMetrics()) ? 0 : $result->getKeywordIdeaMetrics()->getAvgMonthlySearches()->getValue(), is_null($result->getKeywordIdeaMetrics()) ? 0 : $result->getKeywordIdeaMetrics()->getCompetition(), PHP_EOL ); return 

The result is like : Keyword idea text 'a' has 1600 average monthly searches and competition as 4. Keyword idea text 'b' has 10 average monthly searches and competition as 2. Keyword idea text 'c' has 10 average monthly searches and competition as 4.

this is how is printed

i want to return like "a,b,c"

How to store this result in one string and to retunr ....so then i can use in other function