Facebook ad creative with call to action returns no permission for call_to_action

2.6k views Asked by At

I am trying to create a Facebook ad using Facebook Marketing Api.

When I try to ad a call to action button to ad Creative I get an error stating:

(
    [code] => 100
    [error_subcode] => 
    [message] => (#100) No permission to access call_to_action
    [error_user_title] => 
    [error_user_msg] => 
    [error_blame_field_specs] => 
    [type] => OAuthException
)

The same error is produced when using graph apiGraph API

Any help?

1

There are 1 answers

0
Rishiraj Purohit On BEST ANSWER

I was able to find a way around this problem by using link data, check this

https://www.facebook.com/groups/pmdcommunity/permalink/1291740050878460/

here is relevant code which can be used

use FacebookAds\Object\AdCreative;
use FacebookAds\Object\AdCreativeLinkData;
use FacebookAds\Object\Fields\AdCreativeLinkDataFields;
use FacebookAds\Object\AdCreativeObjectStorySpec;
use FacebookAds\Object\Fields\AdCreativeObjectStorySpecFields;
use FacebookAds\Object\Fields\AdCreativeFields;
use FacebookAds\Object\Values\AdCreativeCallToActionTypeValues;

$link_data = new AdCreativeLinkData();
$link_data->setData(array(
  AdCreativeLinkDataFields::MESSAGE => 'try it out',
  AdCreativeLinkDataFields::LINK => '<URL>',
  AdCreativeLinkDataFields::CAPTION => 'My caption',
  AdCreativeLinkDataFields::CALL_TO_ACTION => array(
    'type' => AdCreativeCallToActionTypeValues::SIGN_UP,
    'value' => array(
      'link' => '<URL>',
      'link_caption' => 'Sign up!',
    ),
  ),
));

$object_story_spec = new AdCreativeObjectStorySpec();
$object_story_spec->setData(array(
  AdCreativeObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
  AdCreativeObjectStorySpecFields::LINK_DATA => $link_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();

obtained from here : https://developers.facebook.com/docs/marketing-api/reference/ad-creative-link-data/?hc_location=ufi