我按照http://dalibornasevic.com/posts/35-how-to-send-private-messages-with-facebook-api中提供的说明向我的朋友发送消息,目前正在从命令行进行测试。以下是我正在使用的代码
require 'xmpp4r_facebook'
id = '<my facebook id>@chat.facebook.com'
to = '<my friend facebook id>@chat.facebook.com'
body = "hello, Im not spam!"
subject = 'message from ruby'
message = Jabber::Message.new to, body
message.subject = subject
client = Jabber::Client.new Jabber::JID.new(id)
client.connect
client.auth_sasl(Jabber::SASL::XFacebookPlatform.new(client, '<App ID>', '<access token got from https://developers.facebook.com/tools/explorer>', 'App Secret'), nil)
我收到错误
RuntimeError: not-authorized
from /Users/apple/.rvm/gems/ruby-1.9.3-p194/gems/xmpp4r_facebook-0.1.1/lib/xmpp4r_facebook.rb:103:in `auth'
from /Users/apple/.rvm/gems/ruby-1.9.3-p194/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:171:in `auth_sasl'
from (irb):12
from /Users/apple/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
答案 0 :(得分:2)
听起来您没有授权xmpp_login
权限,因为消息显示
未授权的
如果您拥有正确的权限,它应该有效,您应该得到类似于
的回复<iq xmlns='jabber:client' type='result' id='2027'> ... </>
检查您的访问令牌