关于returnurl:Facebook Callback将“#_ = _”附加到返回URL

Facebook Callback appends '#_=_' to Return URL

facebook回调已经开始向返回的url追加#_=_哈希下划线

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


通过Facebook的平台更新:

Change in Session Redirect Behavior

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请求中设置重定向u uri,如下所示:(使用facebook php sdk)

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

更新

以上就是文档所说的解决这个问题的方法。然而,Facebook的书面解决方案不起作用。请考虑在Facebook平台更新博客帖子上发表评论,并关注此错误以获得更好的答案。在此之前,请将以下内容添加到头部标签以解决此问题:

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

或者更详细的选择(感谢Niftylettuce):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<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;
        }
    }