posting a swf in facebook feed through facebook api

二次信任 提交于 2019-12-04 14:04:31

The type should be "video" instead of "flash". Here's a parameter array that produced a playable video in my tests:

array(
    'type'=>'video',
    'source'=>'http://www.hackerdude.com/channels-test/swfscout_VideoSample.swf',
    'picture'=> 'http://fbrell.com/f8.jpg',
    'name'=> 'Facebook Dialogs',
    'caption'=> 'Reference Documentation',
    'description'=> 'Using Dialogs to interact with users.',
);

Note that there's no link attribute, that's because as it seems to me, the facebook API has a bug at this moment where if you provide a link then it won't embed your video.

The bug theory reinforced by that the JS SDK does indeed accept a link and produce a playable video, you could migrate to this method for publishing if its feasable, with parameters like this:

FB.ui({
     method:'feed',
     type: 'video',
     name: 'Facebook Dialogs',
     link: 'https://developers.facebook.com/docs/reference/dialogs/',
     picture: 'http://fbrell.com/f8.jpg',
     caption: 'Reference Documentation',
     source: 'http://www.hackerdude.com/channels-test/swfscout_VideoSample.swf',
     description: 'Using Dialogs to interact with users.'
});

Workaround

The embedding seem to be working fine if you post a link that has the proper opengraph meta tags for video embedding, here's an example:

the link to be shared (video brought to you by youtube)

<html>
<head>
    <title>Fly, you fools!</title>
    <meta property="og:title" content="Fly, you fools!" />
    <meta property="og:type" content="website"/>
    <meta property="og:description" content="Content for Description" />
    <meta property="og:image" content="http://i2.ytimg.com/vi/meOCdyS7ORE/mqdefault.jpg" />
    <meta property="og:site_name" content="Content for caption"/>
    <meta property="og:video" content="http://www.youtube.com/v/meOCdyS7ORE?version=3&autohide=1">
    <meta property="og:video:type" content="application/x-shockwave-flash">
    <meta property="og:video:width" content="640">
    <meta property="og:video:height" content="360">
</head>
<body>
<script>
    window.location = 'http://disney.com'; // redirecting users who's clicking on the link, wont affect crawlers since its in js.
</script>
</body>
</html>

php sdk call to share it

$this->facebook->api('/me/feed', 'post', array(
    'type' => 'link',
    'link' => 'http://.../', // put the html file's location here
));

write one more met tag : <meta property="og:video:secure_url" content="https://...game url."> "

try to put "https:// " game url ,i.e game swf url with ssl, because fb takes only ssl url to play videos or swf file for game.

Hope this will be useful.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!