简体   繁体   English

使用Javascript将动画GIF分享到Facebook

[英]Share animated GIF to Facebook using Javascript

Now that Facebook supports the sharing of animated GIFs, I want to make a simple button that shares a selected GIF from a gallery, like this: 现在,Facebook支持共享动画GIF,我要创建一个简单的按钮,以共享从图库中选择的GIF,如下所示:

var obj = { 
    method: 'feed',
    source: 'http://img-9gag-fun.9cache.com/photo/aApVdqZ_460sa.gif',
    picture: 'http://img-9gag-fun.9cache.com/photo/aApVdqZ_460sa.gif',
    name: 'FB POST NAME GIF',
    caption: 'FB POST CAPTION GIF',
    description: 'FB POST MESSAGE GIF'
};
FB.ui(obj);

But it doesn't work. 但这是行不通的。

If I post that URL directly, the wall works perfectly but through the action it (javascript) just makes a normal post as if it were a JPG. 如果我直接发布该URL,则墙可以很好地工作,但是通过操作(javascript),它只能像JPG一样进行常规发布。

Does anyone knows how to fix this? 有谁知道如何解决这个问题?

Thanks 谢谢

I've faced the same problem and I found a solution to post GIFs on Facebook 我遇到了同样的问题,我找到了一种在Facebook上发布GIF的解决方案

use the method me/feed/ and put the gif url under the link object 使用方法me/feed/并将gif网址放在link对象下

example: 例:

FB.api(
  'me/feed/',
  'POST',
  {
    message: 'This is a GIF',
    link: 'http://25.media.tumblr.com/08d54accc4beb56a50e752fd931c6b58/tumblr_mlsyqrzwWQ1s3g3ago1_400.gif'
  },
  function(response) {
    console.log(response);
  }
);

It worked for me I hope it works for you. 它对我有用,我希望对您有用。

PS: I'm using the 2.5 API. PS:我正在使用2.5 API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM