通过facebook api在facebook Feed中发布swf

Pet*_*ter 3 post facebook feed news-feed facebook-graph-api

我使用下面的数组和

$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.');
Run Code Online (Sandbox Code Playgroud)

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

com*_*857 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.',
);
Run Code Online (Sandbox Code Playgroud)

请注意,没有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.'
});
Run Code Online (Sandbox Code Playgroud)

解决方法

如果您发布一个具有适当视频嵌入的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>
Run Code Online (Sandbox Code Playgroud)

php sdk调用分享它

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