代码之家  ›  专栏  ›  技术社区  ›  notbrain

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

  •  1
  • notbrain  · 技术社区  · 14 年前

    我浏览了facebooker的msg档案库、google等,发现了一些与此相关的信息,他们基本上说“去看看facebook的文档,看看发生了什么”。我做到了,但我仍然不清楚发生了什么,为什么我不能检索我的个人资料或状态阵列使用facebook。我开始认为facebooker的直接api调用是“断开的”,接下来将尝试等效的fql查询。

    我是不是错过了facebook用户初始化之类的东西? 我查过电话的来源,我打的电话似乎正是我要找的。

    我得到的错误是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
    

    错误:

    [..]/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 回复  |  直到 14 年前
        1
  •  0
  •   notbrain    14 年前

    我做这件事比必须做的要困难得多(而且错误地使用了facebook)。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