views:

202

answers:

1

I've gone through the Facebooker msg archive, google, etc and found a couple messages dealing with this and they basically say "Go look at the Facebook docs and see what is happening". I did that, but I'm still not clear what is going on and why I'm not able to retrieve my profile or status arrays using Facebooker. I'm starting to think that the Facebooker direct API calls are "broken" and am going to try the equivalent FQL queries next.

Am I missing some sort of Facebooker User initialization or something? I've looked at the source, and the calls I'm making seem to be exactly what I'm looking for.

The error I'm getting is API_EC_INFO_NO_INFORMATION, "No information has been set for this user". When I check my profile using the FB Tool Console, I see my info just fine.

What I'm trying to do is set up a beanstalk job to pull FB profile/status info, like so:

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
A: 

I was making this much harder than it had to be (and using Facebooker incorrectly). The session.user object just needed to be populated before use, no need to use an external/explicit Facebooker::User object.

File: 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
notbrain