Redirect back to facebook page tab after authentication?

684 Views Asked by At

im using drupal for facebook for my page tab app, and have a certain issue with it -

after authentication, the user is redirected through a custom module, with the code below -

<?php
function fb_example_fb($op, $data, &$return) {
  $fb_app = isset($data['fb_app']) ? $data['fb_app'] : NULL;
  $fb = isset($data['fb']) ? $data['fb'] : NULL;
  if ($op == FB_OP_AJAX_EVENT) {

    if ($data['event_type'] == 'session_change') {
      if ($fbu = fb_facebook_user()) {
        $url = url('http://apps.facebook.com/appname',
                   array('absolute' => TRUE, 'fb_canvas' => fb_is_canvas()));
        $return[] = 'FB_JS.reload("'. $url .'");';
      }
    }
  }
}
?>

everything works great when i want the user to be redirected to the canvas app. the problem is, i wish for the user to be "redirected" back to the page tab after authenticating, hence i need to refresh the iframe / the main content div, so as soon as the user clicks the "LOGIN" button and authenticate, the page tab would be updated with custom driven content. my goal is to serve it to the users without ever making them leave the tab.

when i try to set the $url path in the code above to - https://www.facebook.com/appname/app_4557794143 (the path for the page tab), i get the following error from facebook after the page refreshes, instead of showing the tab - "

Sorry, your request could not be processed. Please try again"

how can i change the function so the window would be refreshed after pressing the connect button? can someone please shed some light on approaching this the right way? thanks a lot everyone.

1

There are 1 best solutions below

0
DataB On

at the end the solution was quite simple, kind of a hack... for some reason nothing worked when i tried to redirect through fb.js, and facebook kept giving the same error. so, the only thing left to do was to "override" fb.js.redirect and use -

  if ($fbu = fb_facebook_user()) {
    $return[] = 'top.location.href="https://www.facebook.com/exampleapp/app_707794143";';
  }

for all of the future googlers out there...