Код: Выделить всё
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());
}
Ошибка 404 (не найдена)!!1
Запрошенное URL /v14/customers/vvvv/googleAds:searchStream не найден на этом сервере. Это все, что мы знаем.
Подробнее здесь: https://stackoverflow.com/questions/790 ... on-example
Мобильная версия