Hi there,
I used following code for adding Ad to a AdGroup.
////////////////////////////////////////////////////////////////////////////////////////////////
const AD_GROUP_ID = '46481580951';
public static function runExample(AdWordsServices $adWordsServices,
AdWordsSession $session, $adGroupId) {
$adGroupAdService = $adWordsServices->get($session,
AdGroupAdService::class);
// Create the expanded Dynamic Search Ad. This ad will have its
headline
// and final URL auto-generated at serving time according to domain
name
// specific information provided by DynamicSearchAdsSetting at the
// campaign level.
$expandedDSA = new ExpandedDynamicSearchAd();
// Set the ad description.
$expandedDSA->setDisplayUrl('www.abc.com');
$expandedDSA->setFinalUrls(['www.abc.com']);
$expandedDSA->setDescription('Dummy description');
// Create the ad group ad.
$adGroupAd = new AdGroupAd();
$adGroupAd->setAdGroupId($adGroupId);
$adGroupAd->setAd($expandedDSA);
// Create the operation.
$operation = new AdGroupAdOperation();
$operation->setOperator(Operator::ADD);
$operation->setOperand($adGroupAd);
// Create the ad on the server and print some information.
$result = $adGroupAdService->mutate([$operation]);
$newAdGroupAd = $result->getValue()[0];
$expandedDSA = $newAdGroupAd->getAd();
printf(
"Expanded Dynamic Search Ad with ID %d and description '%s'
was"
. " added.\n", $expandedDSA->getId(),
$expandedDSA->getDescription()
);
}
//////////////////////////////////////////////////////////////////////////////
I got 2 error ,
1- EntityNotFound.INVALID_ID @ operations[0].operand.adGroupId;
trigger:'AdGroupId: 2147483647', As my
const AD_GROUP_ID = '46481580951'; is converted integer.
2- When I modified the XML to overcome above error, I got new error
Uncaught exception 'Google\AdsApi\AdWords\v201705\cm\ApiException' with
message '[OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_AD_GROUP_TYPE @
operations[0].operand.ad;
Can anyone help me out with the issue.
Thanks,
Prashant More
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/27f44b72-272f-4868-8a25-c222790c0582%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.