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
table).
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",
@api_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
`process''
from
/home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/parser.rb:15:in
`parse''
from
/home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/service.rb:14:in
`post''
from
/home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/session.rb:466:in
`post_without_logging''
from
/home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/session.rb:477:in
`post''
from
/home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/logging.rb:16:in
`log_fb_api''
from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/benchmark.rb:8:in
`realtime''
from
/home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/logging.rb:16:in
`log_fb_api''
from
/home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/session.rb:476:in
`post''
from
/home/Gooth/projects/rails/posterous/vendor/plugins/facebooker/lib/facebooker/session.rb:167:in
`fql_query''
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.
Vince