如何解决在谷歌api(php)中为app_ad创建AdGroupAd时的分段错误



我正试图使用现有的groupAd创建一个AdGroupAd,但我得到了一个"分段故障";错误消息我已经做了一天多了,但由于缺乏错误的细节,我很难理解出了什么问题

在码头上运行

客户端库:v5.0.0

谷歌广告API:v5.0

PHP 7.4.12(cli((构建时间:2020年11月5日20:24:10((NTS(

Zend Engine v3.4.0,

ionCube PHP加载器+ionCube24 v10.4.4

Zend OPcache v7.4.12

protobuff 3.14.0

grpc 1.33.1

我的代码:假设createAdGroupAd((是用$adGroup参数中adGroup的有效资源名称调用的在这种情况下,类型是CreativeType_Asset::type_YOUTUBE(尽管我尝试了两种类型,但都给出了错误(

public function createAdGroupAd($adGroup, $data) {
$service = $this->client->getAdGroupAdServiceClient();
$ad = $this->createAd($data, $data['asset']->type);
$adGroupAd = new AdGroupAd([
'ad' => $ad,
'status' => AdGroupAdStatus::PAUSED,
'ad_group' =>  $adGroup
]);
$adGroupAdOperation = new AdGroupAdOperation();
$adGroupAdOperation->setCreate($adGroupAd);
//this is the call causing the error
$response = $service->mutateAdGroupAds(
$this->customerId,
[$adGroupAdOperation]
);
return $response->getResults()->count() > 0 ? $response->getResults()[0]->getResourceName() : null;
}
public function createAd($data, $adType = null) {
$service = $this->client->getAdServiceClient();
$appAdInfo = new AppAdInfo([
'headlines' => array_map(function ($headline) {
new AdTextAsset(['text' => $headline]);
}, [$data['creative']->title1, $data['creative']->title2]),
'descriptions' => array_map(function ($description) {
new AdTextAsset(['text' => $description]);
}, [$data['creative']->description1, $data['creative']->description2])
]);
switch ($adType) {
case CreativeType_Asset::TYPE_IMAGE:
$appAdInfo->setImages([new AdImageAsset(['asset' => $data['assetResourceName']])]);
break;
case CreativeType_Asset::TYPE_YOUTUBE:
$appAdInfo->setYoutubeVideos([new AdVideoAsset(['asset' => $data['assetResourceName']])]);
break;
default:
break;
}
return new Ad([
'app_ad' => $appAdInfo,
'type' => AdType::APP_AD]);
}

缺少问题"返回";AppAdInfo构建部分的array_map函数中的语句。

最新更新