0

I have a video's on my website and want to add Share button then users can share that video on Facebook.I can share only image.

Initiate FB appID code:

<script src="http://connect.facebook.net/en_US/all.js"></script>    
    <script>
        window.fbAsyncInit = function() {
            FB.init({appId: '1500007870295396', status: true, cookie: true,
            xfbml: true});
        };
        (function() {
            var e = document.createElement('script'); e.async = true;
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            document.getElementById('fb-root').appendChild(e);
        }());
    </script>

Sample HTML code.

   <button class="fbShare"
      data-href="http://temp.pickzy.com/ccc/images/user_post/post-photo-1452022482-1.mp4"
      data-width="500"
      data-allowfullscreen="true"
      data-autoplay="true">Share Video On FB</button> 

Share the video script code.

<script>
    $('.fbShare').click(function(e){    
        e.preventDefault();
        FB.ui({
            method: 'feed',
            name: 'NAME OF YOUR VIDEO',
            link: 'http://temp.pickzy.com/ccc/images/user_post/post-photo-1452022482-1.mp4',
            picture: 'http://temp.pickzy.com/ccc/images/10.PNG',
            caption: 'YOUR CAPTION',
            description: 'YOUR DESCRIPTION',
        });
    });         
    </script>

Any idea? Or any other method to add this button on the website?

Ramalingam Perumal
  • 1,367
  • 2
  • 17
  • 46
  • 1
    You need to share an HTML document, that references the video via Open Graph meta tags. https://developers.facebook.com/docs/sharing/webmasters#video – CBroe Jan 06 '16 at 09:39
  • It wasn't share the video. Can you share the code? – Ramalingam Perumal Jan 06 '16 at 09:50
  • Code for what? Please be more precise in describing what you’re having problems with. – CBroe Jan 06 '16 at 10:24
  • In my code "http://temp.pickzy.com/ccc/images/user_post/post-photo-1452022482-1.mp4" is not shared but youtube video's like "https://www.youtube.com/watch?v=M6Sw_ePEXg4" are shared. This is a problem. – Ramalingam Perumal Jan 06 '16 at 10:38
  • As I said already, you can not share the video URL directly – you have to share an HTML document instead, that refers the video. – CBroe Jan 06 '16 at 10:40

0 Answers0