Beispiel #1
0
 public function createVideoPost($pageAccessToken, Post $post)
 {
     $url = sprintf('https://graph-video.facebook.com/%s/%s/videos', self::API_VERSION, $this->pageId);
     $formData = ['multipart' => [['name' => 'title', 'contents' => $post->getName()], ['name' => 'picture', 'contents' => $post->getPicture()], ['name' => 'published', 'contents' => $post->getPublished() ? '1' : '0'], ['name' => 'call_to_action', 'contents' => json_encode($post->getCallToAction())], ['name' => 'access_token', 'contents' => $pageAccessToken], ['name' => 'source', 'contents' => fopen($post->getSource(), 'r'), 'filename' => basename($post->getSource())]]];
     $response = $this->client->request('POST', $url, $formData);
     $responseData = json_decode($response->getBody(), true);
     $postId = $responseData['id'];
     return $postId;
 }
 private function uploadVideo(Post $post)
 {
     // $file stores the uploaded PDF file
     /** @var UploadedFile $file */
     $file = $post->getSource();
     // Generate a unique name for the file before saving it
     $fileName = $file->getClientOriginalName();
     // Move the file to the directory where brochures are stored
     $uploadDir = $this->getParameter('kernel.root_dir') . '/../web/uploads/videos';
     $file->move($uploadDir, $fileName);
     // Update the 'brochure' property to store the PDF file name
     // instead of its contents
     $post->setSource($uploadDir . '/' . $fileName);
 }