Object story spec is ill formed. Maybe missing Page ID or creative details, or invalid fields exist

I was using marketing Api for facebook and php-facebook-sdk something. I was able to create a campaign and adset and upload a video and now I'm on the part wherein I need to create AdCreative. I find it hard to look for a video_data with the correct object story spec or something like that, so I tried creating based on information that I gathered accross the net and here's what I came up with.

try {
        $fields = array(
        );
        $params = array(
          'url_tags' => 'utm_source=facebook',
          'object_story_spec' => array('page_id' =>  $page_id, 'video_data' =>  array('call_to_action' =>  array('type' =>  'WATCH_VIDEO')), 'image_url' => $image_url, 'video_id' => $video_id),
          'name' => 'My Bolbs',
          'applink_treatment' => 'web_only',
        );
        $creative = (new AdAccount($ad_account_id))->createAdCreative(
          $fields,
          $params
        );
        $creative_id = $creative->id;
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e, "\n";
    }

The error it was throwing to me was this

["error"]=>
array(8) {
  ["message"]=>
  string(17) "Invalid parameter"
  ["type"]=>
  string(14) "OAuthException"
  ["code"]=>
  int(100)
  ["error_subcode"]=>
  int(1443048)
  ["is_transient"]=>
  bool(false)
  ["error_user_title"]=>
  string(34) "object_story_spec param is invalid"
  ["error_user_msg"]=>
  string(99) "Object story spec is ill formed. Maybe missing Page ID or creative details, or invalid fields exist"
  ["fbtrace_id"]=>
  string(11) "Hmti64698Rr"
}

I was wondering if I can ask for any advice on how to fix this error.

Thanks and advance thank you to all those who will suggest and give advice.

Upvotes: 0

Views: 17423

Answers (1)

R0l
R0l

Reputation: 434

Your 'object_story_spec' array is not formed correctly. 'image_url' and 'video_id' are out of 'video_data' array. The correct array should be:

'object_story_spec' => array(
   'page_id' =>  $page_id, 
   'video_data' =>  array(
      'call_to_action' =>  array('type' =>  'WATCH_VIDEO'), 
      'image_url' => $image_url, 
      'video_id' => $video_id
   )
)

Upvotes: 0

Related Questions