我正在使用Facebook ads api管理来自我的应用程序的广告,并为此使用了fb PHP sdk 3.0。 我正在尝试制作图片广告,并使用以下代码。
$account_id = "<MY_ACOUNT_ID>";
$ad_account = new AdAccount($account_id);
$photo_data = new AdCreativePhotoData();
$photo_data->setData( array( AdCreativePhotoDataFields::URL => $data['url']) );
$object_story_spec = new AdCreativeObjectStorySpec();
$object_story_spec->setData(array(
AdCreativeObjectStorySpecFields::PAGE_ID => <MY_PAGE_ID>,
AdCreativeObjectStorySpecFields::PHOTO_DATA => $photo_data,
'link'=>$data['link']
));
$creative_params = array();
$creative = new AdCreative(null, $account_id);
$creative_params['name'] = 'MY TEST ADS FROM API';
$creative_params['link_url'] = '<LINK URL OF IMAGE/WEBSITE>';
$creative_params['object_story_spec'] = $object_story_spec;
$creative->setData( $creative_params );
try{
$creative->create();
$fields = array();
$params = array(
'name' => 'MY TEST IMAGE ADS : VISH',
'adset_id' => $data['adset_id'],
'creative' => array('creative_id' => $creative->id),
'status' => $data['status'],
);
try{
$ads = $ad_account->createAd($fields, $params);
return $ads->id;
} catch (Exception $e){
throw new Exception($e->getErrorUserTitle());
}
} catch (Exception $e){
throw new Exception($e->getErrorUserTitle());
}
这会在Facebook中生成广告,但是当我在广告管理器面板中看到其预览时,就会显示此错误。