Take the 2-minute tour ×

I created an App (inside a Page Tab). Now I check if the App has all permissions, if not I ask for them:

 //$app_url = Url to Page Tab
'<script>top.location.href = "'.$facebook->getLoginUrl('next' => $app_url, 'scope' => $scope).'";</script>'

Now I want that it redirect to the Page Tab (App) after asking for permissions, but it always redirects to my domain.

Tried it first with 'redirect_uri', but that throws errors (outdated), and also with 'next'.

Any ideas, except checking in the APP if the User is on Facebook?

ps. couldn't find a up to date solution.

edit: Just saw when I try the app as a admin the following error is displayed: API Error Code: 191 API Error Description: The specified URL is not owned by the application

share|improve this question
I think you have to check the user has authed your app and is on facebook in the app itself otherwise you can't make api calls. –  Sammaye Aug 8 '12 at 9:00
Is your $app_url the url to your site or the tab on facebook? e.g facebook.com/page/app Also you should try passing an array into getLoginUrl like so getLoginUrl(array('next' => $app_url, 'scope' => $scope)); as that's what it expects developers.facebook.com/docs/reference/php/facebook-getLoginUrl –  TommyBs Aug 8 '12 at 9:30
Hey, it's passing an array, just simplyfied the code for posting. And the $app_url contains the link to the facebook page/app (facebook.com/page/app). I also added a error code in the first post. –  Mek Aug 8 '12 at 9:40
Yea try changing your apps settings to the domain you are pointing to on redirect, that is basically what it says, if the app settings page does not have a URL or callback domain that matches the one sent in via the API method it will bail with that error message –  Sammaye Aug 8 '12 at 10:50
I want to redirect to facebook (page tab), but I can't insert facebook as a host in the settings. –  Mek Aug 8 '12 at 12:20
add comment

1 Answer

For redirect to your app Tab, if you use PHP Facebook SDK you can do:

$signedRequest = $facebook->getSignedRequest();
if(!empty($signedRequest) && !empty($signedRequest['page']['id'])){
    $page = $facebook->api($signedRequest['page']);

$redirect_uri = $page['link'] . '?sk=app_' . $facebook->getAppId();

$loginUrl = $facebook->getLoginUrl(array(
    'scope' => 'publish_actions',
    'redirect_uri' => $redirect_uri

And then, in your HTML you put:

<script>top.location.href = "<?php echo $loginUrl; ?>";</script>

Also, in your APP configuration you have to point (Page Tab URL & Secure Page Tab URL) to your domain and folder where is your application.

share|improve this answer
add comment

Your Answer


