Question

Comment envoyer une invitation à un contact Gtalk avec bibliothèque java smack?

Était-ce utile?

La solution

//Setting up connection
ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
        connection = new XMPPConnection(config);
        connection.connect();
//login
        connection.login(userName, password);
//get your roster   
    Roster roster = connection.getRoster();
//add a new roster entry aka SEND INVITATION

roster.createEntry(address, name, groups);

Pour plus de détails regarder cette page: http: //www.igniterealtime .org / builds / smack / docs / 3.1.0 / javadoc / org / Jive Software / smack / Roster.html

Autres conseils

En utilisant le code ci-dessous, vous pouvez construire le contact avec Gtalk.

ConnectionConfiguration conf = new ConnectionConfiguration(  
        "talk.google.com",  
        5222,  
        "gmail.com");  
conf.setSASLAuthenticationEnabled(false);
XMPPConnection con = new XMPPConnection(conf);  
con.connect();  
/* 
 * username : username@gmail.com

 * password : 
 */  
con.login("username", "password");  

Vous pouvez obtenir un contact Gtalk comme suit:

GoogleTalkConnection con = new GoogleTalkConnection();
con.login(”joesmith”, “password”);
con.createChat(”maryjane@gmail.com”).sendMessage(”Howdy!”);
con.close();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top