I have little problem. When I need my app to ask user to grant permissions to the app I use following code:
<?php
$loginUrl = $facebook->getLoginUrl(
array(
'canvas' => 1,
'fbconnect' => 0,
'scope' => 'email,publish_stream,offline_access',
));
?>
echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
I works OK, but after user press "grant permissions" he is redirected to my app URL. I mean like http://mydomain.com/myapp/ directly, not my app page on Facebook. I can work around it - I know my app's Facebook address, so I redirect him to proper http://apps.facebook.com/myappname. It works OK too. BUT - when somebody adds my application on some page tab - here is where problem appears. Because I don't know where to redirect user anymore - I don't know, from what page my app was called.
Is there any way to get to know, from what page my app was called, or, even better, to make Facebook properly redirect user to the "facebook page" where app tab were added after "grant permission" dialog ?
Step 1: In Facebook, click the small arrow near your name in the upper-right-hand corner and choose Privacy Settings. Step 2: Scroll down to Apps and Web sites and click on Edit Settings off to the right. Step 3: If the app you want to adjust is in the recently used list, click on it to edit settings.
Tap in the top right of Facebook. Scroll down and tap Settings. Go to the Permissions section and tap Apps and Websites. Go to Apps, Websites and Games and tap Edit.
You can set redirect_uri
like so:
<?php
$loginUrl = $facebook->getLoginUrl(
array(
'canvas' => 1,
'fbconnect' => 0,
'scope' => 'email,publish_stream,offline_access',
'redirect_uri' => 'http://yourdomain.com/app', //the url to go to after a successful login
));
echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
?>
Seems to be the only thing you can do is detect if the user is viewing your page from outside of facebook and then redirect them to your facebook app page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With