发布到 Facebook 后如何关闭弹出窗口? [英] How do I close the popup after I post to facebook?

查看:27
本文介绍了发布到 Facebook 后如何关闭弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的博客上,我们有一个链接,用户可以将我们的文章发布到他们的时间线.打开一个弹出窗口,用户发布到 facebook,然后弹出窗口停留在那里并重定向到www.oursite.com".当用户完成发布或单击取消按钮时,我们如何关闭弹出窗口?根据 这个问题无法完成,但赫芬顿邮报已经弄清楚了,但是查看他们的代码我们无法弄清楚.例如,此处的facebook分享按钮将打开一个弹出窗口,然后在您发布文章或取消文章时关闭.

On our blog we have a link where users can post our articles to their timeline. A popup opens up and the user posts to facebook, then the popup stays there and redirects to "www.oursite.com". How do we instead close the popup when the user either finishes posting or clicks on the cancel button? According to this so question it can't be done but Huffington post has figured it out but looking at their code we can't figure it out. As an example, the facebook share button here will open up a popup and then close when you either post the article or cancel.

这就是我们所拥有的:

FB.init({appId: "90210", status: true, cookie: true});

      function postToFeed() {

        // calling the API ...
        var obj = {
          method: 'feed',
          redirect_uri: 'http://www.oursite.com/',
          link: 'http://www.oursite.com/',
          picture: 'http://www.oursite.com/png.png',
          name: 'Some title',
          caption: '',
          description: ''
        };

        function callback(response){
           window.close(); // doesn't do anything
          //document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
        }

        FB.ui(obj, callback);
      }

我们已经尝试添加 window.close();在回调中(还有 self.close();),尝试将 redirect_uri 留空(并尝试将 redirect_uri 完全留空,但这是必需的).

We've tried adding window.close(); in the callback (and also self.close();), tried leaving redirect_uri blank (and tried leaving redirect_uri out altogether, but it's required).

推荐答案

截至 2017 年 10 月,删除 redirect_uri 似乎可行.

As of 10/2017 removing redirect_uri seems to work.

它将默认为 https://www.facebook.com/dialog/return/close#_=_

其来源只是 <脚本类型="文本/javascript">window.close() </script>

这篇关于发布到 Facebook 后如何关闭弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆