Skip to content

Commit 166088c

Browse files
Christine LuLuca Bruno
authored andcommitted
Add support for video creation using image slideshows
Summary: Introduced slideshow_spec to AdVideo and added new file SlideshowSpecFields to hold sub-fields. slideshow can still be used against graph-video endpoint, so continue to do so in AdVideo creation but adjust to not require a source video file Test Plan: use FacebookAds\Object\AdVideo; use FacebookAds\Object\Fields\AdVideoFields; $video = new AdVideo(null, $ad_account_id); $video->{AdVideoFields::SLIDESHOW_SPEC} = array ( 'images_urls' => array( $image_url_1, $image_url_2, $image_url_3, ), 'duration_ms' => 2000, 'transition_ms' => 200, ); $video->create();
1 parent c6b8a77 commit 166088c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/FacebookAds/Object/AdVideo.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ public static function getFieldsEnum() {
4949

5050
public function create(array $params = array()) {
5151
$data = $this->exportData();
52-
$source = $data[AdVideoFields::SOURCE];
53-
unset($data[AdVideoFields::SOURCE]);
52+
$source = null;
53+
if (array_key_exists(AdVideoFields::SOURCE, $data)) {
54+
$source = $data[AdVideoFields::SOURCE];
55+
unset($data[AdVideoFields::SOURCE]);
56+
}
5457
$params = array_merge($data, $params);
5558

5659
$request = $this->getApi()->prepareRequest(
@@ -60,7 +63,9 @@ public function create(array $params = array()) {
6063
);
6164

6265
$request->setLastLevelDomain('graph-video');
63-
$request->getFileParams()->offsetSet(AdVideoFields::SOURCE, $source);
66+
if ($source) {
67+
$request->getFileParams()->offsetSet(AdVideoFields::SOURCE, $source);
68+
}
6469
$response = $this->getApi()->executeRequest($request);
6570

6671
$data = $response->getContent();

src/FacebookAds/Object/Fields/AdVideoFields.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class AdVideoFields extends AbstractEnum {
4242
const NAME = 'name';
4343
const PICTURE = 'picture';
4444
const PUBLISHED = 'published';
45+
const SLIDESHOW_SPEC = 'slideshow_spec';
4546
const SOURCE = 'source';
4647
const UPDATED_TIME = 'updated_time';
4748
const THUMBNAILS = 'thumbnails';

0 commit comments

Comments
 (0)