vincent chu
2009-Feb-02 08:23 UTC
[Facebooker-talk] Stymied on FB Connect ''show permissions dialog''
Hi all -- I''m pretty stuck here trying to implement a feature using FB Connect. The basic idea is for me to request an offline_access extended permission, capture the updated session key, then save it to a user object on my site. The strategy I''ve been using is as follows: 0) I embed a hidden form with a user id hash 1) I add a link "enable offline access". The link has an onclick call to a javascript function ''add_fb_account()'' 2) the js function ''add_fb_account'' is really simple: function add_fb_account() { FB.Connect.showPermissionDialog(''offline_access'', function(accepted) { document.getElementById(''add_fb_user_form'').submit(); } ); } The idea is for the user to click the link, up pops the dialog, then a form is passed to a controller which will associate the updated session_key to the user stored int the user hash. The problem is that the session_keys aren''t updated until the next time the user reloads a page with a call to FB.Facebook.init, which is too late for my server-side code to capture a valid session_key. This is because all of the server-side code that captures the session_key is executed *before* the html-based javascript code that would update the cookies. Very annoying! I can''t, for the life of me, figure out how to tell the ''showPermissionDialog'' to update the session keys before submitting the form. If I could figure this out, then the session_keys would be updated by the javascript before redirecting to the form-controller page, which would then execute the servier-side code to grab the session key. I feel like this is possible -- I''m looking for behavior similar to the login-window where the session-key is set immediately after the user logs in to FB Connect (before being passed to the next page). Can anyone suggest anything? Thanks, Vince