1

我浏览了 Facebooker msg 档案、谷歌等,发现了几条处理这个问题的消息,他们基本上说“去看看 Facebook 文档,看看发生了什么”。我这样做了,但我仍然不清楚发生了什么以及为什么我无法使用 Facebooker 检索我的个人资料或状态数组。我开始认为 Facebooker 直接 API 调用已“损坏”,接下来将尝试等效的 FQL 查询。

我是否缺少某种 Facebooker 用户初始化或其他内容?我查看了源代码,我正在拨打的电话似乎正是我正在寻找的。

我得到的错误是 API_EC_INFO_NO_INFORMATION,“没有为此用户设置信息”。当我使用 FB Tool Console 检查我的个人资料时,我可以看到我的信息。

我正在尝试做的是设置一个 beanstalk 工作来提取 FB 配置文件/状态信息,如下所示:

sess = Facebooker::Session.create("<key>", "<secret_key>")

# session_key passed to beanstalk as body payload
sess.secure_with! job.body

fbkr_user = Facebooker::User.new(sess.user.id, sess)

puts fbkr_user.get_profile_info.to_s    # info not set error

# same result if I go through the session, or try to get user.statuses
puts sess.user.get_profile_info
puts sess.user.statuses

错误:

[..]/gems/facebooker-1.0.62/lib/facebooker/parser.rb:646:in `process':
No information has been set for this user (StandardError)
       from /Users/notbrain/.gem/ruby/1.8/gems/facebooker-1.0.62/lib/
facebooker/parser.rb:36:in `parse'
       from /Users/notbrain/.gem/ruby/1.8/gems/facebooker-1.0.62/lib/
facebooker/service.rb:66:in `post'
       from /Users/notbrain/.gem/ruby/1.8/gems/facebooker-1.0.62/lib/
facebooker/session.rb:638:in `post_without_logging'
       from /Users/notbrain/.gem/ruby/1.8/gems/facebooker-1.0.62/lib/
facebooker/session.rb:649:in `post'
       from /Users/notbrain/.gem/ruby/1.8/gems/facebooker-1.0.62/lib/
facebooker/logging.rb:20:in `log_fb_api'
       from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/benchmark.rb:308:in `realtime'
       from /Users/notbrain/.gem/ruby/1.8/gems/facebooker-1.0.62/lib/
facebooker/logging.rb:20:in `log_fb_api'
       from /Users/notbrain/.gem/ruby/1.8/gems/facebooker-1.0.62/lib/
facebooker/session.rb:648:in `post'
       from /Users/notbrain/.gem/ruby/1.8/gems/facebooker-1.0.62/lib/
facebooker/models/user.rb:390:in `get_profile_info'
       from app/workers/index_fb_user.rb:23
       from app/workers/index_fb_user.rb:6:in `loop'
       from app/workers/index_fb_user.rb:6
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `eval'
       from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/commands/runner.rb:
46
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
       from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
`require'
       from script/runner:3
4

1 回答 1

0

我做的比它必须的要困难得多(并且错误地使用了 Facebooker)。session.user 对象只需要在使用前填充,不需要使用外部/显式Facebooker::User对象。

文件:app/workers/fb_processor.rb:

  beanstalk = Beanstalk::Pool.new([BEANSTALK_HOST])
  beanstalk.watch("index-fb-user")

  loop do
    begin
      session_key = job.body
      sess = Facebooker::Session.create(Facebooker.api_key, Facebooker.secret_key)
      sess.secure_with! session_key

      sess.user.populate
      puts sess.user.inspect

    rescue
      puts "Process FB User Failed: #{e.message}"

    ensure
      puts "Deleting job!"
      sess = nil
      # optional, depends on if job is re-spawned elsewhere if fail
      job.delete

    end
  end
于 2010-03-03T02:48:24.707 回答