270 if(!empty($params[
'url_tags']))
272 $updateAdResult = $this->
updateAdUrlTags($accountId, $params[
'url_tags']);
273 if(!$updateAdResult->isSuccess())
275 $result->addErrors($updateAdResult->getErrors());
279 if($this->
hasPublicPages() && !empty($params[
'phone']) || !empty($params[
'email']))
281 foreach($publicPageIds as $publicPageId)
284 if(!$updatePageResult->isSuccess())
286 $result->addErrors($updatePageResult->getErrors());
302 if($adSetResult->isSuccess())
304 $adSetIds = $adSetResult->getData();
315 'fields' =>
'id,adset_id,campaign_id,creative',
320 'endpoint' =>
'act_'.$accountId.
'/ads',
323 if($adsResult->isSuccess())
325 $ads = $adsResult->getData();
329 if(in_array($ad[
'adset_id'], $adSetIds))
334 $adsResult->setData($result);
372 unset($creative[
'id']);
373 foreach($creative as $key => $value)
377 $creative[$key] = Json::encode($value);
383 'endpoint' =>
'act_'.$accountId.
'/adcreatives',
384 'fields' => $creative,
387 if($response->isSuccess())
389 $data = $response->getData();
390 if(isset($data[
'id']))
395 'fields' => [
'creative' => $data[
'id']],
400 $response->addError(
new Error(
'Could not find id after Ad Creative add'));
416 $result = $this->
getAds($accountId);
417 if(!$result->isSuccess() || empty($result->getData()))
422 $ads = $result->getData();
425 if(!isset($ad[
'creative']) || !isset($ad[
'creative'][
'id']))
429 $getAdCreativeResult = $this->
getAdCreative($ad[
'creative'][
'id']);
430 if($getAdCreativeResult->isSuccess())
432 $creative = $getAdCreativeResult->getData();
434 $creative[
'url_tags'] = http_build_query($this->
mergeUrlParams($currentUrlParams, $urlParams));
436 $updateAdCreativeResult = $this->
updateAdCreative($accountId, $ad[
'id'], $creative);
437 if(!$updateAdCreativeResult->isSuccess())
439 $result->addErrors($updateAdCreativeResult->getErrors());
444 $result->addErrors($getAdCreativeResult->getErrors());
481 foreach($newParams as $name => $value)
485 if(isset($currentParams[$name]))
487 unset($currentParams[$name]);
492 $currentParams[$name] = $value;
496 return $currentParams;