如何与JavaScript SDK共享视频?

时间:2011-08-30 20:50:16

标签: video facebook-javascript-sdk

我正在使用FB.ui来允许用户在墙上分享内容。它工作正常,但我希望我能分享一个视频 - 就像你可以用Open Graph标签做的那样。这是我目前的代码:

$('#share').click(function() {
        FB.ui(
        {
            method: 'feed',
            name: 'App name',
            link: 'http://www.facebook.com/pages/mypage',
            picture: 'http://url.com/picture.jpg',
            caption: 'Type in a caption',
            description: 'A description of the share',
        });
    });

使用Open Graph标记,您可以执行以下操作:

<meta property="og:video" content="https://url.com/video.swf" />
<meta property="og:video:height" content="259" />
<meta property="og:video:width" content="398" />
<meta property="og:video:type" content="application/x-shockwave-flash" />
<meta property="og:image" content="https://url.comimage.jpg"/>

当Facebook刮擦您的页面时,他们会使用“播放”按钮将图像放入共享帖子中,然后当您单击它时,SWF会显示。

这适用于JS SDK吗?

由于

1 个答案:

答案 0 :(得分:3)

问题是陈旧的,但答案是:

<!DOCTYPE HTML>
<html lang="en-US">
<head>
      <meta charset="UTF-8">
      <title> Publish </title>
</head>
<body>
      <div id='fb-root'></div>
      <script src='http://connect.facebook.net/en_US/all.js'></script>

      <input type="button" value="Publish " onclick="publish(); return false;" />

<script type="text/javascript">
FB.init({appId: "APP_ID", status: true, cookie: true});

function publish()
{
      var feed = {
            method: 'feed',
            picture: 'THUMB',
            link: 'http://google.com',
            name: 'Google',
            description: 'DESCRIPTION',
            source: 'PATH_TO_SWF_OR_PLAYER_WITH_PARAMETERS',
            type: 'video',
      };

      function callback(response){
            if(response && response.post_id !== undefined) {
                  alert('published');
            }
      }

      FB.ui(feed, callback);
}
</script>
</body>
</html>

更多信息here