我想编写一个应用程序,它将:
因此,当我打开我的gmail界面时,我看到页面左侧有联系人的列表。我可以从这个列表中打开和别人聊天,我可以改变状态和名字(靠近我的小google+化身)。

是否存在一些用于更改Google状态(特殊消息)的google?我能用一些RubyOnRails宝石来做吗?谢谢。
发布于 2013-06-24 11:50:41
因此,这几行红宝石代码(使用xmpp4r gem ),更改您的google_talk状态并将chat_message发送给您的朋友。谢谢你,阿尔坎!
require 'xmpp4r'
# init jabber client
client_jid = Jabber::JID.new( 'your_email@gmail.com' )
client = Jabber::Client.new( client_jid )
client.connect 'talk.google.com'
client.auth 'your_gmail_password'
# change google_talk status
client.send( Jabber::Presence.new.set_show( :chat ).set_status( 'Your New GoogleTalk status' ) )
# send chat_message to friend
friend = Jabber::JID.new("your_friend_email@gmail.com")
message = Jabber::Message::new(friend, "it's chat message").set_type(:normal).set_id('1')
client.send(message)我喜欢红宝石^_^!
发布于 2013-06-24 08:04:49
Gtalk的Xmpp实现。要更改状态,这可能会对您有所帮助。
进口xmpp
进口dns
Gtalk()类:
def __init__(self,bot_id,bot_pwd):
self.bot_id = bot_id
self.bot_pwd = bot_pwd
def connect(self):
self.jid = xmpp.protocol.JID(self.bot_id)
self.presnc = xmpp.protocol.Presence()
self.conn = xmpp.Client(self.jid.getDomain(),debug=[])
if self.conn.connect():
print 'connected..'
self.auth()
else:
print 'err to connect'
def auth(self):
if self.conn.auth(self.jid.getNode(),self.bot_pwd):
self.conn.sendInitPresence()
print 'Authenticated..'
else:
print 'err to authenticate'
def setStatus(self,value):
self.conn.send(xmpp.protocol.Presence(status=value))
def invisible(self,username):
self.conn.send(xmpp.protocol.Presence(username,typ='unavailable'))
def visible(slef,username):
self.conn.send(xmpp.protocol.Presence(username,typ=None))
def disconnect(self):
self.conn.disconnect()https://stackoverflow.com/questions/17255522
复制相似问题