我找到解決方案如何連接的gtalk和jabber.org與啪3.1.0:
代碼的GTalk:
ConnectionConfiguration cc = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
XMPPConnection connection = new XMPPConnection(cc);
try {
connection.connect();
// You have to put this code before you login
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
// You have to specify your gmail addres WITH @gmail.com at the end
connection.login("[email protected]", "password", "resource");
// See if you are authenticated
System.out.println(connection.isAuthenticated());
} catch (XMPPException e1) {
e1.printStackTrace();
}
對於jabber.org這裏是代碼:
ConnectionConfiguration cc = new ConnectionConfiguration("jabber.org", 5222, "jabber.org");
XMPPConnection connection = new XMPPConnection(cc);
try {
connection.connect();
// You have to put this code before you login
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
// You have to specify your Jabber ID addres WITHOUT @jabber.org at the end
connection.login("your.jabber", "password", "resource");
// See if you are authenticated
System.out.println(connection.isAuthenticated());
} catch (XMPPException e1) {
e1.printStackTrace();
}
有了這段代碼,我現在可以連接到我的本地ejabberd和openfire服務器。我希望這能解決你的問題。