错误“无法在广告素材中使用视频。视频ID XXX,XXX,XXX,XXX,XXX可能不是视频ID,或者您可能没有观看权限”

时间:2018-11-11 03:30:30

标签: php facebook-ads-api

我正尝试使用php-facebook-sdk并在curl Facebook API的帮助下制作广告。

我已经使用curl上载了我的视频,并且它返回一个ID。现在,该视频ID将用于添加广告素材,但是当我提交广告素材时,它将返回此错误:

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"
  }
}

所返回的视频ID为191520185101173。

这是我的代码:

 $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,
  );

我还尝试将ID直接(静态地)放置在代码中,如下所示:

'video_id' => '191520185101173',

这样做,它将运行并创建广告,但以某种方式,当我尝试动态使用视频ID时,它将返回该错误。

有什么建议吗?

1 个答案:

答案 0 :(得分:3)

使用以下代码解决您的问题:

@RunWith(MockitoJUnitRunner::class)
class AdminServiceTests {

private lateinit var createAdmin: CreateAdmin

@Mock
lateinit var userRepository: UserRepository

@Mock
lateinit var userRoleRepository: UserRoleRepository

@Mock
lateinit var jwtGenerator: JwtGenerator

@Mock
lateinit var emailService: EmailService

@InjectMocks
lateinit var userService: UserService

@Mock
lateinit var userRepository: UserRepository // Conflicting declarations

@Mock
lateinit var adminRepository: AdminRepository

@InjectMocks
lateinit var adminService: AdminService

@Before
fun setup() {
    this.createAdmin = CreateAdmin().apply {
        email = "admin@gmail.com"
        name = "admin"
        password = "qwerty"
        phone = 9873555555555
    }
}

@Test
fun testCreateAdmin() {
    val result = adminService.createAdmin(createAdmin)
    Assert.assertEquals(true, result)
}
}