Michael Tedesco
2008-Mar-04 00:39 UTC
[Facebooker-talk] Can someone tell me if this is possible
I''d like to make a call to the following URL passing my API_KEY. Two questions http://www.facebook.com/code_gen.php/v=1.0&api_key=MY_API_KEY I''d like to access my stored api_key 1) Can I do it from the following start point t_session = Facebooker::Session.create then somehow access the key 2) I''m also trying to do the following from my Controller def temp_session t_session = Facebooker::Session.create t_session.secure_with!(self.facebook_session_key, self.facebook_uid, 0) return t_session end but I''m getting the following error undefined method `facebook_session_key'' for #<FacebookerController:0x4aa6870> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/facebooker-talk/attachments/20080303/197a1fc9/attachment.html
Joel Watson
2008-Mar-04 03:17 UTC
[Facebooker-talk] Can someone tell me if this is possible
For number one, you want to do something like this: t_session = Facebooker::Session.create(Facebooker::Session.api_key, Facebooker::Session.secret_key) Though I haven''t looked into the underlying code directly, I''m guessing Facebooker::Session.api_key and secret_key are both loaded from your facebooker.yml file at load time. For number two. If that method is in your controller and facebook_session_key is an attribute of your user model, then the problem is self.facebook_session_key is attemping to call facebook_session_key on the controller, not your user object. I would move that method to your user model and then call it in your controller. class User < ActiveRecord::Base def restore_facebook_session return @facebook_session unless @facebook_session.nil? @facebook_session = Facebooker::Session.create(Facebooker::Session.api_key, Facebooker::Session.secret_key) @facebook_session.secure_with!(facebook_session_key, facebook_uid, 0) @facebook_session end end where facebook_session_key and facebook_uid are attributes of your User. class FacebookController < ApplicationController def some_action @user = User.find(params[:id]) @facebook_session = @user.restore_facebook_session # do stuff with your facebook session end end -Joel On Mar 3, 2008, at 4:39 PM, Michael Tedesco wrote:> I?d like to make a call to the following URL passing my API_KEY. > Two questions > > http://www.facebook.com/code_gen.php/v=1.0&api_key=MY_API_KEY > > I?d like to access my stored api_key > 1) Can I do it from the following start point > t_session = Facebooker::Session.create > > then somehow access the key > > 2) I?m also trying to do the following from my Controller > def temp_session > t_session = Facebooker::Session.create > t_session.secure_with!(self.facebook_session_key, > self.facebook_uid, 0) > return t_session > end > > but I?m getting the following error > undefined method `facebook_session_key'' for > #<FacebookerController:0x4aa6870> > > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/facebooker-talk/attachments/20080303/c495491c/attachment-0001.html
Michael Tedesco
2008-Mar-04 17:07 UTC
[Facebooker-talk] Can someone tell me if this is possible
Thanks Joel: Does facebooker have a similar function to the following - to return facebook generated session key facebook.auth.getSession ? n Thanks, Mike From: Joel Watson [mailto:joel at i5labs.com] Sent: Monday, March 03, 2008 10:17 PM To: Michael Tedesco Cc: facebooker-talk at rubyforge.org Subject: Re: [Facebooker-talk] Can someone tell me if this is possible For number one, you want to do something like this: t_session = Facebooker::Session.create(Facebooker::Session.api_key, Facebooker::Session.secret_key) Though I haven''t looked into the underlying code directly, I''m guessing Facebooker::Session.api_key and secret_key are both loaded from your facebooker.yml file at load time. For number two. If that method is in your controller and facebook_session_key is an attribute of your user model, then the problem is self.facebook_session_key is attemping to call facebook_session_key on the controller, not your user object. I would move that method to your user model and then call it in your controller. class User < ActiveRecord::Base def restore_facebook_session return @facebook_session unless @facebook_session.nil? @facebook_session = Facebooker::Session.create(Facebooker::Session.api_key, Facebooker::Session.secret_key) @facebook_session.secure_with!(facebook_session_key, facebook_uid, 0) @facebook_session end end where facebook_session_key and facebook_uid are attributes of your User. class FacebookController < ApplicationController def some_action @user = User.find(params[:id]) @facebook_session = @user.restore_facebook_session # do stuff with your facebook session end end -Joel On Mar 3, 2008, at 4:39 PM, Michael Tedesco wrote: I''d like to make a call to the following URL passing my API_KEY. Two questions http://www.facebook.com/code_gen.php/v=1.0&api_key=MY_API_KEY I''d like to access my stored api_key 1) Can I do it from the following start point t_session = Facebooker::Session.create then somehow access the key 2) I''m also trying to do the following from my Controller def temp_session t_session = Facebooker::Session.create t_session.secure_with!(self.facebook_session_key, self.facebook_uid, 0) return t_session end but I''m getting the following error undefined method `facebook_session_key'' for #<FacebookerController:0x4aa6870> _______________________________________________ Facebooker-talk mailing list Facebooker-talk at rubyforge.org<mailto:Facebooker-talk at rubyforge.org> http://rubyforge.org/mailman/listinfo/facebooker-talk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/facebooker-talk/attachments/20080304/41950d3c/attachment.html
Joel Watson
2008-Mar-05 00:46 UTC
[Facebooker-talk] Can someone tell me if this is possible
The session key is accessible with "your_session.session_key". So, by default in your facebook controller with the requisite ensure filters, you will have a session accessible via facebook_session. So, you would get it like this: class FacebookController < ApplicationController ensure_application_is_installed_by_facebook_user def some_action @user = User.new @user.facebook_session_key = facebook_session.session_key @user.facebook_uid = facebook_session.user.uid @user.save end end Is that what you were after? -Joel On Mar 4, 2008, at 9:07 AM, Michael Tedesco wrote:> Thanks Joel: > > Does facebooker have a similar function to the following - to > return facebook generated session key > > facebook.auth.getSession ? > > n Thanks, Mike-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/facebooker-talk/attachments/20080304/d5c3cd5d/attachment.html