开发者

How do you share a video with the JavaScript SDK?

开发者 https://www.devze.com 2023-03-31 16:33 出处:网络
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:

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消