Ejemplo n.º 1
0
 protected function doSubmit(KalturaDistributionSubmitJobData $data)
 {
     $videoPath = $data->providerData->videoAssetFilePath;
     if (!$videoPath) {
         throw new Exception('No video asset to distribute, the job will fail');
     }
     if (!file_exists($videoPath)) {
         throw new KalturaDistributionException("The file [{$videoPath}] was not found (probably not synced yet), the job will retry");
     }
     $facebookMetadata = $this->convertToFacebookData($data->providerData->fieldValues, true);
     try {
         /** on submission of a video we can take care of the following :
          * 1. video content
          * 2. thumbnail
          * 3. call to action
          * 4. name + description
          * 5. place
          * 6. tags
          * 7. targeting
          * 8. scheduled_publishing_time
          * 9. feed targeting
          */
         $data->remoteId = FacebookGraphSdkUtils::uploadVideo($this->appId, $this->appSecret, $data->distributionProfile->pageId, $data->distributionProfile->pageAccessToken, $videoPath, $data->providerData->thumbAssetFilePath, filesize($videoPath), $this->tempDirectory, $facebookMetadata);
     } catch (Exception $e) {
         throw new Exception("Failed to submit facebook video , reason:" . $e->getMessage());
     }
     if ($data->providerData->captionsInfo) {
         foreach ($data->providerData->captionsInfo as $captionInfo) {
             $this->submitCaption($data->distributionProfile, $captionInfo, $data->remoteId);
         }
     }
     return true;
 }