如何使用 JavaScript SDK 共享视频?

发布于 2024-12-02 07:51:15 字数 948 浏览 0 评论 0原文

我正在使用 FB.ui 来允许用户将某些内容分享到他们的墙上。它工作得很好,但我希望我可以分享一个视频 - 就像你可以使用开放图标签一样。这是我当前的代码:

$('#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 实现吗?

谢谢

I'm using FB.ui to allow users to share something to their wall. It works fine, but I was hoping I could share a video - like you can do with the Open Graph tags. Here is my current code:

$('#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',
        });
    });

With the Open Graph tags you can do the following:

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

When Facebook scrapes your page, they put the image in the shared post with a "play" button, then when you click it the SWF shows up.

Is this doable with the JS SDK?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

源来凯始玺欢你 2024-12-09 07:51:15

这个问题很老了,但答案如下:

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

更多信息此处

The question is old, but here's the answer:

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

More information here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文