gpt4 book ai didi

ruby-on-rails - 使用 xmpp4r_facebook 发送消息时出错

转载 作者:太空宇宙 更新时间:2023-11-03 16:06:24 24 4
gpt4 key购买 nike

我正在按照 http://dalibornasevic.com/posts/35-how-to-send-private-messages-with-facebook-api 中提供的说明进行操作向我的 friend 发送消息,目前正在从命令行进行测试。以下是我使用的代码

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>'

最佳答案

听起来您没有像消息中所说的那样授予 xmpp_login 权限

not-authorized

如果你有正确的权限,它应该可以工作,你应该得到类似于

的响应
<iq xmlns='jabber:client' type='result' id='2027'> ... </> 

使用 https://developers.facebook.com/tools/debug 检查您的访问 token

关于ruby-on-rails - 使用 xmpp4r_facebook 发送消息时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12862304/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com