ruby - 有没有可以更改 google-talk 状态的 API?

标签 ruby google-api xmpp google-talk xmpp4r

我想编写一个应用程序,它将:

  • 接收和发送电子邮件(我知道,我可以用 使用 RoR 的 ActionMailer )
  • 与我的 Google+ 好友聊天
  • 更改我的 GoogleTalk (gmail) 状态

因此,当我打开 Gmail 界面时,我会在页面左侧看到包含我的联系人的列表。我可以与此列表中的人打开聊天,我可以更改状态和名称(靠近我的小 google+ 头像)。

When I write status or name, I meen special message 'Bogdan' on this picture

是否存在一些用于更改 google-talk 状态的 Google API(特殊消息)?我可以使用一些 RubyOnRails gem 来实现吗? 谢谢。

最佳答案

所以,这行漂亮的 ruby​​ 代码(使用 xmpp4r gem ), 更改您的 google_talk 状态并向您的 friend 发送 chat_message。 谢谢你,@Arkan!

require 'xmpp4r'

# init jabber client
client_jid = Jabber::JID.new( '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a1d8ced4d3fec4ccc0c8cde1c6ccc0c8cd8fc2cecc" rel="noreferrer noopener nofollow">[email protected]</a>' )
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("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="037a6c76715c65716a666d675c666e626a6f43646e626a6f2d606c6e" rel="noreferrer noopener nofollow">[email protected]</a>")    
message = Jabber::Message::new(friend, "it's chat message").set_type(:normal).set_id('1')
client.send(message)

我喜欢 ruby ^_^!

关于ruby - 有没有可以更改 google-talk 状态的 API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17255522/

相关文章:

java - Smack XMPP 自定义扩展未完全到达

ios - iOS:无法获取XMPP聊天的脱机消息

android - 无法从 Android 上的 xmpp 服务器获取公共(public)房间列表?

ruby-on-rails - 测试 Rspec 中未定义方法 `user_path'

ruby-on-rails - Docker 镜像在 Ubuntu 16.04 上工作,但在 Ubuntu 18.04 上失败

php - 无法使用 PHP 在 google apis 请求中添加多个范围

ruby-on-rails - Rails 4 - 使用omniauth-google-oauth2的Google一次性代码流,不断收到 "Invalid code"

Ruby 的 GServer 只想在本地主机上工作

上传到 S3 时 Ruby Backup gem 失败。 37 分钟后连接重置

python - 在电子表格上添加行超过 100 秒用户配额