コード例 #1
0
 /**
  * @param array $fields
  * @param array $params
  * @return Cursor
  */
 public function getAdVideos(array $fields = array(), array $params = array())
 {
     return $this->getManyByConnection(AdVideo::className(), $fields, $params);
 }
コード例 #2
0
if (is_null($data) || !is_array($data['data']) || count($data['data']) === 0) {
    throw new \RuntimeException("no promotable posts available for page " . $page_id);
}
$post_id = $data['data'][0]['id'];
// create Ad Image
$zip_path = $config->testZippedImagesPath;
$images = AdImage::createFromZip($zip_path, $ad_account_id);
$image_1_hash = $images[0]->{AdImageFields::HASH};
$image_2_hash = $images[1]->{AdImageFields::HASH};
$image_3_hash = $images[1]->{AdImageFields::HASH};
// create Ad Video
$retry_delay = 3;
$max_retry = 4;
$video_name = $config->testRunId;
$video_path = $config->testVideoPath;
$video = new AdVideo(null, $ad_account_id);
$video->setData(array(AdVideoFields::NAME => $video_name, AdVideoFields::SOURCE => $video_path));
$video->create();
$video_id = $video->{AdVideoFields::ID};
$video_thumbnails = null;
while (--$max_retry >= 0) {
    sleep($retry_delay);
    $video_thumbnails = $video->getApi()->call('/' . $video_id . '/thumbnails', RequestInterface::METHOD_GET)->getContent();
    if ($video_thumbnails && count($video_thumbnails['data']) > 0) {
        break;
    }
}
if (is_null($video_thumbnails) || !is_array($video_thumbnails['data']) || count($video_thumbnails['data']) === 0) {
    throw new \RuntimeException("no thumbnails available for video " . $video_id . ", please try again");
}
$video_image_url = $video_thumbnails['data'][0]['uri'];