如何克隆 ImageAd 和 ResponsiveDisplayAd
How to clone ImageAd and ResponsiveDisplayAd
我们需要更新 finalUrls
的所有广告。我们有数百个 ImageAd
和 ResponsiveDisplayAd
,我们不想丢失现有的配置 and/or 图像。由于 Google 不允许我们更新 AdGroupAd
的任何 属性 除了状态,我们将不得不使用 ADD
运算符克隆它们。
在执行此操作时,我们遇到了几个错误,所有错误都与 ad.image
有关。 correct/best 进行这些更新的方法是什么?
[AdError.IMAGE_ERROR @ operations[0].operand.ad]
首先,我通过一点谷歌搜索发现 adToCopyImageFrom
是我必须使用的,以便复制广告的图像属性(仅 ImageAd
!)以便克隆。因此,如果 $currentAd
是包含现有 ImageAd
的 AdGroupAd
对象,而您正在尝试创建一个新对象 $newAd
并希望复制图像,那么您可以这样做做(不确定这是否是最好的方法,但对我来说效果很好!):
$newAd = new ImageAd();
$newAd = $ad->ad;
// Let Google do the image copying
// Remember $currentAd is a AdGroupAd and not an Ad
$newAd->adToCopyImageFrom = $currentAd->ad->id;
$newAd->id = null;
$newAd->image = null;
同样,对于 ResponsiveDisplayAd
,我是这样做的:
$newRespAd = new ResponsiveDisplayAd();
// Make sure you included MediaId while fetching
// $currentRespAd
$newRespAd = $currentRespAd->ad;
$newRespAd->id = null;
我们需要更新 finalUrls
的所有广告。我们有数百个 ImageAd
和 ResponsiveDisplayAd
,我们不想丢失现有的配置 and/or 图像。由于 Google 不允许我们更新 AdGroupAd
的任何 属性 除了状态,我们将不得不使用 ADD
运算符克隆它们。
在执行此操作时,我们遇到了几个错误,所有错误都与 ad.image
有关。 correct/best 进行这些更新的方法是什么?
[AdError.IMAGE_ERROR @ operations[0].operand.ad]
首先,我通过一点谷歌搜索发现 adToCopyImageFrom
是我必须使用的,以便复制广告的图像属性(仅 ImageAd
!)以便克隆。因此,如果 $currentAd
是包含现有 ImageAd
的 AdGroupAd
对象,而您正在尝试创建一个新对象 $newAd
并希望复制图像,那么您可以这样做做(不确定这是否是最好的方法,但对我来说效果很好!):
$newAd = new ImageAd();
$newAd = $ad->ad;
// Let Google do the image copying
// Remember $currentAd is a AdGroupAd and not an Ad
$newAd->adToCopyImageFrom = $currentAd->ad->id;
$newAd->id = null;
$newAd->image = null;
同样,对于 ResponsiveDisplayAd
,我是这样做的:
$newRespAd = new ResponsiveDisplayAd();
// Make sure you included MediaId while fetching
// $currentRespAd
$newRespAd = $currentRespAd->ad;
$newRespAd->id = null;