[Facebooker-talk] Facebooker offline_access

vincent chu vincentchu at gmail.com
Wed Oct 1 14:40:45 EDT 2008

Hi All --

I just watched Mike's excellent screencasts on facebooker. Anyway, I'd
like to move beyond those examples to some more complicated ones, but
am having trouble conceptualizing a few points.

I'd like to develop an application that pushes content to a user's
profile box / news feed (and possibly photos, etc..) OFFLINE. However,
from what I gather, all of the entries in the User table that was
generated by facebooker_authentication all have expiration times. To
me, this means that my app can only push updates when the user is
logged in to facebook and has pinged my app (which updates the User

The natural solution seems to be the fb_prompt_permission call to
facebooker, which I included as:

<%= fb_prompt_permission "offline_access", "Let the app have offline access" %>

My question is this: how do I update the User table at this point to
reflect the fact that the session is no infinite? Any sample code
would be *very* helpful since I'm not only new at facebooker, I'm
pretty new at RoR.


Next question: I'd also like to periodically check to see what
permissions my application has (e.g., does my app still have an
infinite session, or was this revoked by the user at some point). To
do this, I'd like to query the FQL permissions table (
http://wiki.developers.facebook.com/index.php/Permissions_(FQL) ).
However, I wasn't able to figure out how to get a valid session to
query the database with. Experimenting in the console, I first created
a Facebooker::Session:

>> session = Facebooker::Session.new(Facebooker::Session.api_key, Facebooker::Session.secret_key)
=> #<Facebooker::Session:0x7fe9ae24 @secret_key="XXX", @api_key="XXX">

It seems like I can make fql queries on publicly available information:

>> session.fql_query('select name from user where uid=509113181')
=> [#<Facebooker::User:0x7f2e11dc @name="David Morin",
@populated=true, @session=#<Facebooker::Session:0x7fe9ae24
@service=#<Facebooker::Service:0x7ff0911c @api_path="/restserver.php",
@api_base="api.new.facebook.com", @api_key="XXX">, @secret_key="XXX",

However, I can't make any fql queries on private information. This is
pretty obvious because I don't have a valid session key:

>> session.fql_query('select uid from permissions where email=1')
Facebooker::Session::SessionExpired: Session key invalid or no longer valid:
        from /home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/parser.rb:462:in
        from /home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/parser.rb:15:in
        from /home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/service.rb:14:in
        from /home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/session.rb:466:in
        from /home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/session.rb:477:in
        from /home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/logging.rb:16:in
        from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/benchmark.rb:8:in
        from /home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/logging.rb:16:in
        from /home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/session.rb:476:in
        from /home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/session.rb:167:in
        from (irb):10

So, my question is: How do I get a valid session key "offline" so that
I can run maintainence tasks offline?

Cheers, and thanks for the help.


More information about the Facebooker-talk mailing list