开发者

strophe to register user on ejabberdctl

开发者 https://www.devze.com 2023-01-23 12:43 出处:网络
I开发者_如何学Go would like to add a user on ejabberd server using strophe with out typing ejabberdctl register uname servename passwd at command prompt. Is it possible to implement?. Is there any

I开发者_如何学Go would like to add a user on ejabberd server using strophe with out typing ejabberdctl register uname servename passwd at command prompt. Is it possible to implement?. Is there any XMPP protocol exists to register an user?

Thanks Sathi


Yes it is possible... you need to allow for inline registration on the server. Once that's done, you can certainly do it from any client or client library, include strophe.js.


Use mod_admin_extra and mod_rest then you get a full restfull access to jabberctl + some extra commands. Search the module documentation for more information on how to set this up.


I am using strophe.register.js

$("#register").click(function () {              

    var connect = new Strophe.Connection('http://yourserver.com/http-bind');

    var callback = function (status) {

        if ( status === Strophe.Status.REGISTERING ) {
            console.log('REGISTERING')
        }

        else if ( status === Strophe.Status.REGIFAIL ) {
            console.log('REGIFAIL')
        }

        else if ( status === Strophe.Status.REGISTER ) {
            console.log('REGISTER')
            connect.register.fields.username = "joe"
                    connect.register.fields.password = "doe"
                    connect.register.submit();
        }

        else if ( status === Strophe.Status.SUBMITTING ) {
            console.log('SUBMITTING')
        }

        else if ( status === Strophe.Status.SBMTFAIL ) {
            console.log('SBMTFAIL')
            console.log('Something went wrong...');
        }

        else if ( status === Strophe.Status.REGISTERED ) {
            console.log('REGISTERED')

            console.log('Your account has been created successfully and is ready to use!');

        }

    }   

connect.register.connect("yourserver.com", callback);

});
0

精彩评论

暂无评论...
验证码 换一张
取 消