我正在使用Facebook Marketing API,创建广告素材时出现错误。错误是无效的参数。我的想法来自官方文档here
这是我的代码
$creative = new AdCreative(null, 'act_331**********774');
$creative->setData(array(
AdCreativeFields::NAME => 'Sample Creative',
AdCreativeFields::TITLE => 'my title',
AdCreativeFields::BODY => 'my body',
AdCreativeFields::OBJECT_URL => 'https://www.link.com',
AdCreativeFields::LINK_URL => 'https://www.link.com',
AdCreativeFields::IMAGE_HASH => '6fefe3bffe71af42892e64ac9768375e8s',
));
$creative2 = $creative->create();
echo "<pre>"; print_r($creative2->id); die;
预先感谢,请帮助。
答案 0 :(得分:0)
我通过捕获异常解决了这个问题,它告诉我错误。错误是无效的图像哈希。我使用了以下代码。
try {
$this->_creative->setData($this->_postdata);
$creative2 = $this->_creative->create();
$this->_ad->setData(array(
AdFields::NAME => $this->_postdata[AdFields::NAME],
AdFields::ADSET_ID => $this->_adset,
AdFields::CREATIVE => array('creative_id' => $creative2->id),
));
$adresponse = $this->_ad->create(array(
Ad::STATUS_PARAM_NAME => Ad::STATUS_PAUSED,
));
echo "<pre>"; print_r($adresponse);
} catch (RequestException $ex) {
print_r($ex->getResponse()->getContent());
}