0

My tab needs to know the date when a user becomes fan, so i've to ask for permissions. Despite facebook official documentation, i made it successfully and the user is redirected to the oauth dialog and after he confirms, back to the tab.

$user = $facebook->getUser();
if ($user)
{
    $access_token = $facebook->getAccessToken();
    $user_profile = $facebook->api('/me');
    try
    {
        $likes = $facebook->api("/me/likes/pageid");
    }
    catch (FacebookApiException $e)
    {
        $user = null;
    }
}
else
{
    ?>
    <script type="text/javascript">
        var oauth_url = 'https://www.facebook.com/dialog/oauth/';
        oauth_url += '?client_id=<?=$app_id?>';
        oauth_url += '&redirect_uri=' + encodeURIComponent('https://www.facebook.com/<?=$pageid?>?sk=app_<?=$app_id?>');
        oauth_url += '&scope='
        window.top.location = oauth_url;
    </script>
    <?
    die();
}

All works, but i'm not able to parse the error response in case users don't accept the dialog. The returning url is:

https://www.facebook.com/page?sk=app_appid&error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.#_=_

But the iframe inside tab doesn't have any parameters.

What can i do?

4

1 に答える 1

0

You can only pass data to the iframe on the tab using the app_data parameter in the URL. You will have to redirect unsuccessful login attempts to a URL like:

https://www.facebook.com/{your_page}?v=app_{app_id}&app_data={your_string}

E.g. https://www.facebook.com/{your_page}?v=app_{app_id}&app_data=login_failed

The login_failed still will appear in the decoded signed_request

于 2012-05-30T10:44:09.883 に答える