我正在尝试向我的XMPP服务器添加新用户。我正在使用strophe.register.js,这是我的代码
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);
})当我单击#registerBtn时,我希望用uname: juliet和pass: R0m30创建用户。
相反,我在控制台中得到了错误: TypeError: that._buildBody不是来自strophe.register.js第106行的函数
我检查了几乎所有的xmpp连接的问题,我无法找到解决办法。
我尝试过这个解决方案:Register XMPP-Account using the Strophe.js-Register-Pluging,但它对我不起作用。有人知道吗?
发布于 2014-06-26 03:47:27
我也有同样的问题。我用https://github.com/strophe/strophejs-plugins/tree/master/register修复了它。此外,确保connection.register.connect("192.168.1.77/bosh/",回调( 60,1)中的"192.168.1.77/bosh/“被您在XMPP服务器注册的主机的名称替换,比如ejabberd。例如“example.com”或“localhost”等等。
https://stackoverflow.com/questions/23369063
复制相似问题