Error "Unable to use the video in an ad creative. Video id XXX,XXX,XXX,XXX,XXX might not be id of a video, or you might not have permission to see it"

Roi Patrick Florentino picture Roi Patrick Florentino · Nov 11, 2018 · Viewed 43.2k times · Source

I'm trying to create an ad using the php-facebook-sdk and with the help of curl Facebook API.

I already have uploaded my video with the use of curl and it returns an id. Now, that video id will be used to add an adcreative, but when I submit my adcreative it returns this error:

object(stdClass)#568 (1) {
["error"]=>
object(stdClass)#563 (8) {
  ["message"]=>
  string(17) "Invalid parameter"
  ["type"]=>
  string(14) "OAuthException"
  ["code"]=>
  int(100)
  ["error_subcode"]=>
  int(2013004)
  ["is_transient"]=>
  bool(false)
  ["error_user_title"]=>
  string(28) "Invalid video in ad creative"
  ["error_user_msg"]=>
  string(144) "Unable to use the video in an ad creative. Video id 191,520,185,101,173 might not be id of a video, or you might not have permission to see it. "
  ["fbtrace_id"]=>
  string(11) "HSK5VFCiP6u"
  }
}

The video ID returned by the way is 191520185101173.

Here's my code:

 $object_story_spec = array('page_id' => $page_id,'video_data' => array('video_id' => $video_id,'message' => $ad_message,'image_url' => $image_url,'title' => $ad_header,'call_to_action' => array('type' => 'LEARN_MORE', 'value' => array('link' => $ad_redirect))));
  $params = array(
    'url_tags' => 'utm_source=facebook',
    'image_url' => $image_url,
    'object_story_spec' => json_encode($object_story_spec),
    'access_token' => $pass_token,
  );

I also tried placing that ID straight to the code (statically) like so:

'video_id' => '191520185101173',

And by doing so, it will run and create the adcreative, but somehow when I try using the video ID dynamically, it returns that error.

Any advise?

Answer

Kannan Thamu picture Kannan Thamu · Nov 13, 2018

Use this code to solve your problem:

video.remote_create()
video.waitUntilEncodingReady()