Quickblox: Cannot get users by tag_list. Error: Token is required

Quickblox: Cannot get users by tag_list. Error: Token is required

我需要获取已放入特定房间的用户。房间名称在登录时输入 tag_list 参数。我调整了示例的代码以通过 tag_list 参数获取用户,但它说我需要一个令牌才能获得访问权限。谁能解释我没有复制的示例代码中发生了什么?这是我的代码:

$scope.callees = [$scope.user.id];
$scope.sessionType = QB.webrtc.CallType.VIDEO; // AUDIO is also possible
$scope.session = QB.webrtc.createNewSession($scope.callees, $scope.sessionType);
var mediaParams = {
    audio: true,
    video: true,
    options: {
        muted: true,
        mirror: true
    },
    elemId: 'localVideoEl',
    optional: {
        minWidth: 240,
        maxWidth: 320,
        minHeight: 160,
        maxHeight: 240
    }
};

QB.users.get(
    {
        'tags': [$scope.user.tag_list], 
        'per_page': 100
    }, 
function(err, result){
    if (err) {
        console.log(err);
    } else {
        console.log(result);
    }
});

嗯 Angular 用户...原来答案太令人兴奋了!!! (讽刺)事实证明,您必须将请求包装在另一个 QB.login 和另一个 QB.createSession...

QB.createSession(function(err,result){
    if (result) {
        QB.login($scope.user, function(loginErr, loginUser){
            if (loginErr) {
                console.log('log in error');
                console.log(loginErr);
            }else {

// HANDLE USERS                     

                var params = {tags: [$scope.user.tag_list]};
                QB.users.get(params, function(err, result){
                    if (err){
                        console.log(err);
                    }else{
                        console.log(result);
                    }
                });

// HANDLE CHAT  

                QB.chat.connect(patient, function(err, res) {
                    if (err) { console.log(err); } else { console.log(res); }
                });

// HANDLE VIDEO 

                $scope.callees = [$scope.user.id];
                $scope.sessionType = QB.webrtc.CallType.VIDEO; // AUDIO is also possible
                $scope.session = QB.webrtc.createNewSession($scope.callees, $scope.sessionType);

                var mediaParams = {
                    audio: true,
                    video: true,
                    options: {
                        muted: true,
                        mirror: true
                    },
                    elemId: 'localVideoEl',
                    optional: {
                        minWidth: 240,
                        maxWidth: 320,
                        minHeight: 160,
                        maxHeight: 240
                    }
                };
                $scope.session.getUserMedia(mediaParams, function(err, stream) {
                    if (err){
                        //console.log(err);
                    }else{
                        //console.log(stream);
                    }
                });




            }
        });
    }else if (err) {
        console.log(err);
    }
});

因此,尽管为拥有单页应用程序付出了所有努力,但您仍然必须在每个页面上登录...如果 Angular 社区中的任何人有更好的答案,可以在每次登录后继续登录路线改变我不会讽刺地高兴!请随意列出您的解决方案,我会将其标记为正确的,而不是我的...因为我觉得,这不是真正的答案...