Thank you for responding,
From the
example code to create a ad belong to group id existed so how to create a `ad group ad` with the type which compatible with the it.
Here is my logic code
$gaCampaign = new Campaign([
'name' => $campaignData->name,
'advertising_channel_type' => AdvertisingChannelType::SHOPPING,
'status' => CampaignStatus::ENABLED,
"start_date" => $campaignData->from_date_ymd,
"end_date" => $campaignData->to_date_ymd,
'campaign_budget' => $budgetResourceName
]);
$adGroup = new AdGroup([
'name' => $campaign->name,
'campaign' => $campaignResourceName,
'type' => AdGroupType::SHOPPING_PRODUCT_ADS,
'status' => AdGroupStatus::ENABLED
]);
$ad = new Ad([
"name" => "Ad - " . $campaign->name,
]);
$ad->setType(AdType::EXPANDED_TEXT_AD);
$expandedTextAdInfo = new ExpandedTextAdInfo([
'headline_part1' => $campaign->headline_part1,
'description' => $campaign->description,
]);
if ($campaign->headline_part2 != null && $campaign->headline_part2 != "") {
$expandedTextAdInfo->setHeadlinePart2($campaign->headline_part2);
}
if ($campaign->headline_part3 != null && $campaign->headline_part3 != "") {
$expandedTextAdInfo->setHeadlinePart3($campaign->headline_part3);
}
if ($campaign->description1 != null && $campaign->description1 != "") {
$expandedTextAdInfo->setDescription2($campaign->description1);
}
$ad->setExpandedTextAd($expandedTextAdInfo);
$ad->setFinalUrls([$campaign->final_url]);
$ad->setDisplayUrl($campaign->final_url);
$adGrroupAd = new AdGroupAd([
'status' => AdGroupAdStatus::ENABLED,
'ad_group' => $adGroupResourceName,
'ad' => $ad
]);
But got an error:
Method Name: /google.ads.googleads.v5.services.AdGroupAdService/MutateAdGroupAds
Host:
googleads.googleapis.comHeaders: {
"x-goog-api-client": "gl-php\/7.4.3 gapic\/ gax\/1.5.0 grpc\/1.31.1",
"x-goog-request-params": "customer_id=
3255645407",
"developer-token": "REDACTED",
"login-customer-id": "
3466391933"
}
Request: {"customerId":"
3255645407","operations":[{"create":{"status":"ENABLED","adGroup":"customers/
3255645407/adGroups/111788458237","ad":{"finalUrls":["
seller.quanlythuoc247.com"],"displayUrl":"
seller.quanlythuoc247.com","type":"EXPANDED_TEXT_AD","name":"Ad - Google shopping - US - en#44- 1","expandedTextAd":{"headlinePart1":"Gear GAG","headlinePart2":"Header line 2","headlinePart3":"Header line 3","description":"Gear gag","description2":"Description 2"}}}}]}
Response
-------
Headers: {
"request-id": "QPtTCKJRGtvtXIrUkpEqOA",
"date": "Tue, 20 Oct 2020 19:52:01 GMT",
"alt-svc": "h3-Q050=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-27=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
}
Fault
-------
Status code: 3
Details: Request contains an invalid argument.
Failure: {"errors":[{"errorCode":{"operationAccessDeniedError":"OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE"},"message":"This operation is not permitted on this campaign type","trigger":{"stringValue":"SHOPPING"},"location":{"fieldPathElements":[{"fieldName":"operations","index":"0"},{"fieldName":"create"},{"fieldName":"ad"},{"fieldName":"expanded_text_ad"}]}}]}
Plz help me to fix it.
Vào lúc 10:11:31 UTC+7 ngày Thứ Tư, 21 tháng 10, 2020, adsapiforumadvisor đã viết: