PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 6, 2022

[FIXED] How to upload video and thumbnail to facebook together using PHP SDK?

 January 06, 2022     facebook-graph-api, facebook-php-sdk, php     No comments   

Issue

I want upload video and thumbnail of the video together to Facebook using default facebook sdk.

Please help me to continue work.

Thank you.


Solution

    $fb = new Facebook\Facebook([
            'app_id' => FB_APP_ID,
            'app_secret' => FB_APP_SECRET,
            'default_graph_version' => 'v2.8',
        ]);

        //add parameter to scheduled_publish_time
        $data = [
            'title' => $vid_name,
            'message' => $vid_desc,
            'source' => $fb->fileToUpload(VIDEO_PATH.$vid_id."/".$video['vid_filename']),
        ];
//$thumbfile is thumbnail path.
        if(!empty($thumbfile)){`enter code here`
            $data['thumb'] = imagecreatefromstring(file_get_contents($thumbfile));
        }
    $response = $fb->post('/me/videos', $data, $token);


Answered By - Angel
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing