Pergunta

How to send invitation to gtalk contact with smack java library?

Foi útil?

Solução

//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);

For further details look this page: http://www.igniterealtime.org/builds/smack/docs/3.1.0/javadoc/org/jivesoftware/smack/Roster.html

Outras dicas

Using the code below, you can construct the contact with 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");  

You can achieve Gtalk contact as follows:

GoogleTalkConnection con = new GoogleTalkConnection();
con.login(”joesmith”, “password”);
con.createChat(”maryjane@gmail.com”).sendMessage(”Howdy!”);
con.close();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top