Skip to main content

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


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



Does anyone know why? What is the solution?


Source: Tips4allCCNA FINAL EXAM

Comments

  1. via Facebook's Platform Updates:


    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.


    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'));


    UPDATE

    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 = '';</script>

    ReplyDelete
  2. The Facebook has a frame and inside the frame everything works with AJAX communication. The AJAX solution's biggest problem in this case to show the current state. As far I understand, the Facebook decided that they use simulated anchors. It means if you click somewhere, they simulate that this is an anchor inside the page, and when starts the AJAX communication they change your anchor bit of your URL as well.

    This solution helps you normaly, when you try to reload the page, becuase your borwser send the whole url with anchors to the facebook server / if you refresh the page (not ENTER, press F5)/. So the Facebook pick up the latest state, what you see, and able to continue there.

    When the callback returns with #_ it means nothing changed compare to basic state. Because this anchor parsed by the browser, not need to worry about it.

    ReplyDelete
  3. Not sure why they're doing this but, you could get around this by reseting the hash at the top of your page:

    if (window.location.hash == "#_=_")
    window.location.hash = "";

    ReplyDelete
  4. Major annoying, especially for apps that parse the URI and not just read the $_GET... Here's the hack I threw together... Enjoy!

    <html xmlns:fb='http://www.facebook.com/2008/fbml'>
    <head>
    <script type="text/javascript">
    // Get rid of the Facebook residue hash in the URI
    // Must be done in JS cuz hash only exists client-side
    // IE and Chrome version of the hack
    if (String(window.location.hash).substring(0,1) == "#") {
    window.location.hash = "";
    window.location.href=window.location.href.slice(0, -1);
    }
    // Firefox version of the hack
    if (String(location.hash).substring(0,1) == "#") {
    location.hash = "";
    location.href=location.href.substring(0,location.href.length-3);
    }
    </script>
    </head>
    <body>
    URI should be clean
    </body>
    </html>

    ReplyDelete
  5. if you want to remove the remaining "#" from the url

    if (window.location.hash == '#_=_') {
    window.location.hash = ''; // for older browsers, leaves a # behind
    history.pushState('', document.title, window.location.pathname); // nice and clean
    e.preventDefault(); // no page reload
    }

    ReplyDelete
  6. A change was introduced recently in how Facebook handles session redirects. See "Change in Session Redirect Behavior" in this week's Operation Developer Love blog post for the announcement.

    ReplyDelete
  7. Adding this to my redirect page fixed the problem for me ...

    if (window.location.href.indexOf('#_=_') > 0) {
    window.location = window.location.href.replace(/#.*/, '');
    }

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.