Facebook Page Tab Redirecting Repeatedly

Discussion in 'Facebook API' started by WebDesignTenerife, Sep 2, 2012.

  1. #1
    Hi all.

    I've been using FanGates for some time now and wanted to design something a ittle different and it involved writing an app that captured user data.

    The problem I appear to be having is that I can direct a user to the app quite easily with the following code:

    
    <script>
        var oauth_url = 'https://www.facebook.com/dialog/oauth/';
        oauth_url += '?client_id=XXXXXXXXXX';
        oauth_url += '&redirect_uri=' + encodeURIComponent('https://www.facebook.com/PageName/?sk=app_XXXXXXXXXX);
        oauth_url += '&scope=email'
    
    
        window.top.location = oauth_url;
    </script>
    
    Code (markup):
    I am checking to see if the access token is set with this:

    
    
    
        if (empty($access_token))
        {
    
    Code (markup):
    And then triggering the code above.

    However, it seems to go into a refresh cycle that simply does not stop.

    I've tried forcing it to ask for a token on every load, no joy.

    I know I haven't put much code up here but if someone is willing to help me work on this I would more than happily place the code in pastebin so we can review it together.

    Basically, if I put this code in the header:
    
    <script>    var oauth_url = 'https://www.facebook.com/dialog/oauth/';    oauth_url += '?client_id=XXXXXXXXXX';    oauth_url += '&redirect_uri=' + encodeURIComponent('https://www.facebook.com/PageName/?sk=app_XXXXXXXXXX);    oauth_url += '&scope=email'    window.top.location = oauth_url; [COLOR=#111111]</script>
    [/COLOR]
    Code (markup):
    Then it displays the app and asks for permission. All good.

    But once the user clicks "Go To App" it simply keeps refreshing the page.
    Thanks in advance...
     
    Last edited: Sep 2, 2012
    WebDesignTenerife, Sep 2, 2012 IP