Facebook回调追加'#_ = _'返回URL [英] Facebook Callback appends '#_=_' to Return URL

查看:663
本文介绍了Facebook回调追加'#_ = _'返回URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Facebook回调已经开始向返回网址追加#_ = _ 哈希下划线

Facebook callback has started appending #_=_ hash underscore to the Return URL

有谁知道为什么?什么是解决方案?

Does anyone know why? What is the solution?

推荐答案

通过 Facebook的平台更新


更改会话重定向行为

Change in Session Redirect Behavior

本周,当
此字段留空时,我们开始向redirect_uri添加片段#____ = ____。请确保您的应用程序可以处理此
行为。

This week, we started adding a fragment #____=____ to the redirect_uri when this field is left blank. Please ensure that your app can handle this behavior.

为了防止这种情况,请在登录URL请求中设置redirect_uri,如所以:(使用Facebook php-sdk)

To prevent this, set the redirect_uri in your login url request like so: (using Facebook php-sdk)

$facebook->getLoginUrl(array('redirect_uri' => $_SERVER['SCRIPT_URI'],'scope' => 'user_about_me'));

更新

以上正如文档所述,以解决这个问题。但是,Facebook的文档化解决方案无效。请考虑对 Facebook平台更新博客文章发表评论,并按照这个bug 得到一个更好的答案。在此之前,将以下内容添加到头标中以解决此问题:

The above is exactly as the documentation says to fix this. However, Facebook's documented solution does not work. Please consider leaving a comment on the Facebook Platform Updates blog post and follow this bug to get a better answer. Until then, add the following to your head tag to resolve this issue:

<script type="text/javascript">
    if (window.location.hash && window.location.hash == '#_=_') {
        window.location.hash = '';
    }
</script>

或更详细的选择(谢谢 niftylettuce ):

Or a more detailed alternative (thanks niftylettuce):

<script type="text/javascript">
    if (window.location.hash && window.location.hash == '#_=_') {
        if (window.history && history.pushState) {
            window.history.pushState("", document.title, window.location.pathname);
        } else {
            // Prevent scrolling by storing the page's current scroll offset
            var scroll = {
                top: document.body.scrollTop,
                left: document.body.scrollLeft
            };
            window.location.hash = '';
            // Restore the scroll offset, should be flicker free
            document.body.scrollTop = scroll.top;
            document.body.scrollLeft = scroll.left;
        }
    }
</script>

这篇关于Facebook回调追加'#_ = _'返回URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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