这是我的代码
regXmppClient.SetUsername("abcd");
regXmppClient.SetXmppDomain("abcd.com");
regXmppClient.Password = "abcd";
regXmppClient.RegisterNewAccount = true;
regXmppClient.Open();
regXmppClient.OnRegister += new EventHandler<Matrix.EventArgs>(xmppCon_OnRegister);
regXmppClient.OnRegisterInformation +=
new EventHandler<Matrix.Xmpp.Register.RegisterEventArgs>(xmppCon_OnRegisterInformation);
regXmppClient.OnRegisterError += new EventHandler<Matrix.Xmpp.Client.IqEventArgs>(xmppCon_OnRegisterError);
XMl错误日志
<iq type="error" id="MX_2" from="abcd.com" to="abcd.com/55ce2afc" xmlns="jabber:client">
<query xmlns="jabber:iq:register">
<username>abcd</username>
<password>abcd</password>
<email />
<name />
<x xmlns="jabber:x:data" type="form">
<title>XMPP Client Registration</title>
<instructions>Please provide the following information</instructions>
<field var="FORM_TYPE" type="hidden">
<value>jabber:iq:register</value>
</field>
<field var="username" type="text-single" label="Username">
<required />
</field>
<field var="name" type="text-single" label="Full name" />
<field var="email" type="text-single" label="Email" />
<field var="password" type="text-private" label="Password">
<required />
</field>
</x>
</query>
<error code="400" type="modify">
<jid-malformed xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
</error>
</iq>
答案 0 :(得分:0)
我最终得到了解决方案,我可以使用XmppClientConnection注册新帐户
_xmppConnection.Server = SERVER_NAME;
_xmppConnection.ConnectServer = SERVER_NAME;
_xmppConnection.Username = objxmppData.UserName;
_xmppConnection.Password = objxmppData.password;
**_xmppConnection.RegisterAccount = true;**
_xmppConnection.Open();
_xmppConnection.OnAuthError += loginFailed;
_xmppConnection.OnLogin += new ObjectHandler(xmpp_OnLogin);
如上面的代码那样,使RegisterAccount = true会同时创建新帐户并使用相同的方式登录。
答案 1 :(得分:0)
你的代码提交了一个xdata和旧的jabber样式字段,和。有些服务器有问题,我猜他们是对的。
如果要使用旧的jabber样式注册,请从设置查询中删除xdata。如果要使用xdata,请删除旧的jabber样式字段。
另见:http://forum.ag-software.net/thread/874-How-to-Register-a-new-Account-on-an-xmpp-server