I'm using Facebook Ads API to create unpublished page posts. I have a problem when I try to publish those page posts which are videos with call-to-action button. I create unpublished page posts successfully and then I publish the unpublished posts from power editor, but it shows this message when I try to publish unpublished page posts I created: Sorry, something went wrong. Please try again.
I tried to remove call_to_action
from the code, posts get published without any problem. I'm using Marketing API integrated with my app and use user access token with those permissions:
manage_pages
, publish_pages
, ads_management
, business_management
, public_profile
.
I need help to be able to publish unpublished posts (videos) with CTA button.
Here's the code I use:
$video_data = new AdCreativeVideoData();
$video_data->setData(array(
AdCreativeVideoDataFields::DESCRIPTION => '<DESCRIPTION>',
AdCreativeVideoDataFields::IMAGE_URL => '<IMAGE_URL>',
AdCreativeVideoDataFields::VIDEO_ID => '<VIDEO_ID>',
AdCreativeVideoDataFields::CALL_TO_ACTION => array(
'type' => AdCreativeCallToActionTypeValues::LEARN_MORE,
'value' => array(
'link' => '<URL>',
'link_title' => '<LINK TITLE>',
'link_caption' => '<LINK CAPTION>',
'link_format' => 'VIDEO_LPP',
),
),
));
$object_story_spec = new AdCreativeObjectStorySpec();
$object_story_spec->setData(array(
AdCreativeObjectStorySpecFields::PAGE_ID => '<PAGE_ID>',
AdCreativeObjectStorySpecFields::VIDEO_DATA => $video_data,
));
$creative = new AdCreative(null, 'act_<Ad_ACCOUNT_ID>');
$creative->setData(array(
AdCreativeFields::NAME => 'Sample Creative',
AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
));
$creative->create();
Hope to get help, Thanks!