Hi All,
I want to manage Adwords Ads from my interface.
But I have a problem to get Ad detail from id.
I try to use predicate in selector with AdGroupAd but field 'AdId' or 'Ad' is bad and I have an error.
So I don't know how I can get an Ad by id.
This is more information :
- I use PHP package
- composer package version : "googleads/googleads-php-lib": "^27.1"
- Google version : v201705
- use Sandbox account
This is how I get ads from AdGroupId :
$adGroupAdService = $this->getGoogleService($session, AdGroupAdService::class);
$predicate = new Predicate('AdGroupId', PredicateOperator::IN, ['39244037650']);// TODO dynamic
$adGroupAds = $this->getGoogleData($adGroupAdService, $this->getGoogleField('ad'), [], [$predicate]);
foreach ($adGroupAds as $adGroupAd){
var_dump($adGroupAd->getAd());
}
It works but it's the best way ? There are not other solution ?
And this is how I try to get an Ad by Id :
$adGroupAdService = $this->getGoogleService($session, AdGroupAdService::class);
//$predicate = new Predicate('Ad', PredicateOperator::IN, ['203114498124']);// TODO dynamic
$predicate = new Predicate('AdId', PredicateOperator::IN, ['203114498124']);// TODO dynamic
$adGroupAds = $this->getGoogleData($adGroupAdService, $this->getGoogleField('ad'), [], [$predicate]);
foreach ($adGroupAds as $adGroupAd){
var_dump($adGroupAd->getAd());
}
There are no AdService class, so I try to use predicate and AdGroupAdService to load Ad by id but fields 'AdId' and 'Ad' don't works.
This is error : [SelectorError.INVALID_PREDICATE_FIELD_NAME @ serviceSelector; trigger:'AdId']
I understand fields 'AdId' and 'Ad' are unavailable with AdGroupAd but how I can do to load Ad by Id properly ?
Other information : I have no problem to load report by Ad
If you need more information tell me :)
Thanks