I had same issues too. I got it fixed using this: https://github.com/strophe/strophejs-plugins/tree/master/register. In addition, make sure "192.168.1.77/bosh/" in connection.register.connect("192.168.1.77/bosh/", callback, 60, 1); is replaced by the name of the host you registered with your XMPP server like ejabberd. An example would be 'example.com' or 'localhost' etcetera.
题
I am trying to add new user to my XMPP server. I am using strophe.register.js and here is my code
var callback = function (status) {
if (status === Strophe.Status.REGISTER) {
connection.register.fields.username = "juliet";
connection.register.fields.password = "R0m30";
connection.register.submit();
}
else if (status === Strophe.Status.REGISTERED) {
console.log("registered!");
// calling login will authenticate the registered JID.
connection.register.authenticate();
} else if (status === Strophe.Status.CONFLICT) {
console.log("Contact already existed!");
} else if (status === Strophe.Status.NOTACCEPTABLE) {
console.log("Registration form not properly filled out.")
} else if (status === Strophe.Status.REGIFAIL) {
console.log("The Server does not support In-Band Registration")
} else if (status === Strophe.Status.CONNECTED) {
console.log('logged in')
} else {
console.log("every other status a connection.connect would receive");
}
};
$("#registerBtn").click(function(){
connection.register.connect("192.168.1.77/bosh/", callback, 60, 1);
})
when I click the #registerBtn i expect to have user created with uname: juliet and pass: R0m30.
Instead of that i get this error in console: TypeError: that._buildBody is not a function coming from strophe.register.js line 106
I have checked almost every xmpp-strophe connected question here and I could not find solution.
I tried this solution: Register XMPP-Account using the Strophe.js-Register-Pluging but it did not work for me. Anyone any Idea?
解决方案
不隶属于 StackOverflow