views:

3760

answers:

3

I'm building a facebook connect app to publish content to user's streams. In order to do that, I need to get extended publish_stream permission from the users. I'm using the function code to do so.

Check connection status

<input type="button" onclick="statusSubmit('Permission to publish : ');" value="Check connection status" />

<script type="text/javascript">
function statusSubmit(status)
{
    facebook_prompt_permission('publish_stream', function(accepted)
    {
        if(accepted) {
            // User (already) has permission
            alert(status + 'already granted');
        }
        else
        {
            //  User does not have permission
            alert(status + ' not granted');
        }
    });
}

function facebook_prompt_permission(permission, callbackFunc)
{
    // Check if user has permission, if not invoke dialog.
    FB.ensureInit(function() {
        FB.Connect.requireSession(function(){
            //check is user already granted for this permission or not
            FB.Facebook.apiClient.users_hasAppPermission(permission,
            function(result) {
                // prompt offline permission
                if (result == 0) {
                    // render the permission dialog
                    FB.Connect.showPermissionDialog(permission,
                    function(result){
                        if (null == result)
                            alert('no permissons granted');
                        else
                            alert('permissions ' + result);
                    }, true, null);
                } else {
                    // permission already granted.
                    callbackFunc(true);
                }
            });
        });
    });
}
</script>

After the permissions dialog is displayed and the user grants the permissions, there is a redirect my current page on my local development machine. I cannot seem to control this redirect behaviour through my settings. I have tried changing the "Post-Authorize Callback URL" to a publicly visible page, but it does not get called. Is there something I'm missing? I would like to either

  1. Get the post-authorize callback URL to something that works OR
  2. Even better if there is no redirection after the user grants permissions. This option would be the best.

Thank you for any suggestions.

A: 

I believe that the post-authorize callback url that is set in the application settings only deals with within facebook canvas sort of stuff. What url is called after you authorize the app in facebook.

What I think the best solution is (and this is what i do) is to manually redirect the user after the extended permissions prompt is completed.

window.location = '/path/to/something';
AdamB
A: 

abronte, Thank you for your suggestion. I actually figured out that the path to xd_receiver.htm was incorrect, which was causing all the weird behavior. When I corrected that, things were OK. But the FB Javascript API is very flaky, we decided not to use it as the behavior is erratic. We will be switching to a server based solution in the future.

sammichy
A: 

Sammichy - thank you for posting your solution. As far as I can tell, you're the only person alive that's had this problem that subsequently bothered to make the solution public. Saved me a great deal of monitor bashing. Cheers!

Darrin