mosh
mosh

Reputation: 534

QuickBlox beginner - connecting from desktop

I'm new to QuickBlox. I'm trying to connect to my account from a web page based on the code under the "getting started" in: http://quickblox.com/developers/Web

here is my code. just a simple html form. After submitting (though the details are currntly not really taken from the form, they are hard coded for now) a function is called to establish the connection. The details here are replaced with xxx/yyy/zzz but a real account exsits and the problem is not a result of wrong details given.

When trying to use from the web i always get the message: "something went wrong [object Object]". the result object is also undefined. what am i doing wrong? [I imagine it's somthing basic, so basic it's hard to find reference about it)

Thanks

<head>
</head>
<script src="quickblox.js"></script>

<body>
<div class="container">
    <section id="content" > 
        <form action=""  onsubmit="validate()" 
            <h1>Login Form</h1>
            <div>
                <input type="text" placeholder="Username" required="" id="username" />
            </div>
            <div>
                <input type="password" placeholder="Password" required="" id="password" />
            </div>
            <div>
                <input type="submit" value="Log in" />
                <a href="#">Lost your password?</a>
                <a href="#">Register</a>
            </div>
        </form><!-- form -->    
    </section><!-- content -->
</div><!-- container -->
</body>
</html>
<script> 
function  validate ()
{
    QB.init(xxx,'yyy','zzz');
    QB.createSession(function(err, result)
    {
        if (err)
        {
            alert('Something went wrong: ' + err);
        }
        else
        {
            alert('Session created with id ' + result.id);
        }
    }
    );

}

Upvotes: 0

Views: 303

Answers (1)

WebDev
WebDev

Reputation: 256

QB.init(xxx,'yyy','zzz');
QB.createSession(function(err, result)

This is correct for creating Application session (http://quickblox.com/developers/Authentication_and_Authorization#Summary).

If you need to create the User session, you will need just to add your login (or email) and password to QB.createSession.

For example:

QB.init(xxx,'yyy','zzz');
params = {login: $('#username').val(), password: $('#password').val()};
QB.createSession(params, function(err, result)

Upvotes: 1

Related Questions