如何添加Facebook共享按钮,以便在网站上的Facebook上分享视频

时间:2016-01-06 08:47:11

标签: facebook facebook-php-sdk facebook-share share-button

我的网站上有一个视频,想要添加分享按钮,然后用户可以在Facebook上分享该视频。我只能分享图片。

启动FB appID代码:

<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>

示例HTML代码。

   <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> 

分享视频脚本代码。

<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>

有什么想法吗?或者在网站上添加此按钮的任何其他方法?

0 个答案:

没有答案
相关问题