Share animated GIF to Facebook using Javascript

一个人想着一个人 提交于 2020-01-06 03:18:06

问题


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:

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.

Does anyone knows how to fix this?

Thanks


回答1:


I've faced the same problem and I found a solution to post GIFs on Facebook

use the method me/feed/ and put the gif url under the link object

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.



来源:https://stackoverflow.com/questions/30985793/share-animated-gif-to-facebook-using-javascript

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