Facebooker内置数据检索方法返回“没有为此用户设置的信息”错误

时间:2010-03-02 21:36:35

标签: ruby-on-rails ruby rubygems facebook facebooker

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

我是否错过了某种Facebooker用户初始化或什么?我查看了源代码,而我正在进行的调用似乎正是我正在寻找的。

我得到的错误是API_EC_INFO_NO_INFORMATION,“没有为此用户设置信息”。当我使用FB工具控制台检查我的个人资料时,我看到我的信息就好了。

我正在尝试做的是设置一个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

ERROR:

[..]/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

1 个答案:

答案 0 :(得分: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