Facebook: Requires a valid user is specified (either via the session or via the API parameter for specifying the user.

Posted by Stoic on Stack Overflow See other posts from Stack Overflow or by Stoic
Published on 2010-12-29T18:19:36Z Indexed on 2010/12/29 18:53 UTC
Read the original article Hit count: 132

Filed under:
|
|

Hey Everyone,

I am receiving this error: Requires a valid user is specified (either via the session or via the API parameter for specifying the user. when I am trying to utilize Facebook's FB.api with JS SDK for method: users.hasAppPermission

I am constantly receiving this error, for any uid I pass on. Here is my code:

$(document).ready(function() {
    var perms_requested = <?php echo PERMS;?>;
    var user_id = <?=$user_id;?>;
    $('#perms_check').html(loading);
    ask_for_perms(perms_requested, function(data) {
        $('#perms_check').html(data);
    });
    function ask_for_perms(perms_requested,cb) {
        var request = [];
        $.each(perms_requested,function(i,permission) {
            FB.api({
                method: 'users.hasAppPermission',
                ext_perm: permission,
                uid: user_id
                }, function(response) {
                if (response == 0) request.push(permission);
                if (i == perms_requested.length - 1) cb(request.join(', '));
            });
        });
    }
});

Also, I am utilizing nearly the same code in some other part of the same application, and I am getting fine results with that.

© Stack Overflow or respective owner

Related posts about facebook

Related posts about fbjs