通过facebook api在facebook Feed中发布swf

时间:2012-07-25 12:40:29

标签: facebook facebook-graph-api post feed news-feed

我正在使用以下数组和

$feeddata = array(
                    'type'=>'flash',
                    'method'=>'stream.publish',
                    'display'=>'iframe',
          'link'=> 'https://developers.facebook.com/docs/reference/dialogs/',
          '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.');

并将其传递给facebook-> api($ userid。'/ feed','POST',$ feeddata); 但是在Feed中我只能看到图像,当我点击图像时它会将我带到链接,如何在Feed中看到swf(理想情况下点击图片时应该切换到swf)

2 个答案:

答案 0 :(得分:6)

type应该是“视频”而不是“闪存”。这是一个在我的测试中产生可播放视频的参数数组:

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.',
);

注意没有link属性,这是因为在我看来,facebook API有一个错误,如果你提供一个链接,那么它将不会嵌入你的视频。

由于JS SDK确实接受链接并生成可播放的视频,所以增强了错误理论,如果可行,可以迁移到此方法进行发布,其参数如下:

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.'
});

解决方法

如果您发布一个包含适当视频嵌入的opengraph元标记的链接,嵌入似乎工作正常,这是一个例子:

要分享的链接(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致电分享

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

答案 1 :(得分:1)

再写一个标签: <meta property="og:video:secure_url" content="https://...game url.">

尝试将“https://”游戏网址,即带有ssl的游戏swf网址,因为fb只需要ssl网址来播放视频或swf文件进行游戏。

希望这会有用。