[Facebooker-talk] request for change in URL pointing to facebook domain

David Clements digidigo at gmail.com
Wed Apr 2 14:39:24 EDT 2008


Yeah,
The bebo adapter is a work in progress.  A big hack actually to get things
in production for travelerstable.com.  I was about to split the repo and
start implementing it in a much cleaner way.  I'll put that back on my list
of things todo and see if we can't get a more extensible architecture in
place.

Dave



On Wed, Apr 2, 2008 at 12:10 PM, Jonathan Otto <jonathan.otto at gmail.com>
wrote:

> Dave, Mike et al.,
>
> I like the Bebo adapter, but I was still hoping to have the
> functionality to change the API paths in the plugin, and allow the
> adapters to focus on the API methods.
>
> I have discovered that this is much harder to do than I thought. The
> Facebooker plugin is built in a way that will require quite a bit of
> reconfiguration:
>
> The canvas page, and secret key seem to be getting called from either
> static methods or ENV variables before the session is created, but
> with my additions it is not until the session is created that the
> class methods are ready with the correct canvas page and API URLs.
> Also, the method being used to access the session
> (Facebooker::Session.current) seems to return the hash instead of the
> actual Ruby object.
>
> Changing this is going to require configuration that I am not sure the
> commit team is willing to commit. Still, I have attached what code I
> have added so far. Let me know if you guys want to continue down this
> path and I'll keep working, but until then I'm just going to hardcode
> an adapter (as Dave did) with what I need.
>
> Jonathan
>
> On Tue, Apr 1, 2008 at 4:39 PM, David Clements <digidigo at gmail.com> wrote:
> > Not sure if I am totally following you.
> >
> > In the bebo_adapter I created I overrode the controller method
> >
> >
> >  new_facebook_session  to create the appropriate session object at the
> time
> > the request parameters are processed.  After you have the appropriate
> > Session object then everything should be able to be contained within
> that
> > Session object.  I don't think you need the params being processed
> again.
> >
> > What I was going to do is make sure the
> Facebooker::Sesttion.current_session
> > always hold the correct session.
> >
> >  Then if you need to access some configuration, like deep in
> url_rewriting,
> > you can call Facebooker::Session.current_session.application_base
> >
> > Not sure if that helps.
> >
> > Here are a couple of other issue that might come up.
> >
> > If you are doing any async processing then you will not have an request
> > parameters to go off of so creating the correct session type should be
> > enough to encapsulate all the configuration parameters.  This is another
> > reason why may want to process the parameters once and then have
> everything
> > else go off the current_session object.
> >
> > Hope that helps,  I am attaching the bebo_adapter that I have in
> production
> > right now in case it helps.  There are a lot of other places in bebo
> that
> > the API's don't match up so I have to patch different places in the
> code.
> >
> > Dave
> >
> >
> > On Tue, Apr 1, 2008 at 3:24 PM, Jonathan Otto <jonathan.otto at gmail.com>
> > wrote:
> >
> > > I'm close to getting this working in a fairly DRY fashion. First, a
> > > few questions and some guidance.
> > >
> > > Right now I have all the configuration variables loaded from
> > > facebooker.yml. You can specify 3 different APIs for each RAILS_ENV -
> > > facebook, bebo, or ringside, but if you specify nothing, it defaults
> > > to the Facebook configuration.  When the plugin is initialized it
> > > stores the YAML file into the ENV hash.
> > >
> > > The plan is that the session object will be created by examining the
> > > POST parameters on each request and grabbing the correct configuration
> > > from the ENV hash. Other classes needing the information will call
> > > @session.apps_url, or @session.www_url etc..
> > >
> > > Before I can continue on this route, I need to access the parameters
> > > hash. So is there a built in way to access the parameter hash from the
> > > session class? I could pass it in everywhere
> > > Facebooker::Session.create, or Session.secret_key, etc.. is called,
> > > but that would require a few changes in the controller.
> > >
> > > This seems optimal because it allows each request to your application
> > > to respond to requests from Bebo, Facebook, Ringside, or other future
> > > APIs without reloading the YAML file.
> > >
> > > Please provide suggestions, corrections, or guidance.
> > >
> > >
> > >
> > >
> > > On Tue, Apr 1, 2008 at 8:23 AM, Mike Mangino <
> mmangino at elevatedrails.com>
> > wrote:
> > > >
> > > >  On Apr 1, 2008, at 1:58 AM, Jonathan Otto wrote:
> > > >  > Mike -
> > > >  >
> > > >  > 1) Is the point of making them (the API URLs - currently
> constants)
> > > >  > class methods so they can be more readily changed - as in after
> the
> > > >  > plugin is loaded and during program execution? If it is not, I
> don't
> > > >  > see why my above code wouldn't suffice.
> > > >  >
> > > >
> > > >  They would change based upon the type of session used. Facebook
> will
> > > >  not change their API url during execution, so there is no need for
> > > >  that to change during requests. Each different container will have
> > > >  it's own session object.
> > > >
> > > >
> > > >  > 2) If you guys plan on letting these URLs change during program
> > > >  > execution, how will you detect what API to set the configuration
> for?
> > > >  > The POST params might be the same (At least I suspect they are
> the
> > > >  > same for Bebo and Facebook, Ringside however does have some
> unique
> > > >  > additions).
> > > >
> > > >  You need some way to tell what site you are talking to. Facebook
> and
> > > >  Bebo have different parameters. Bebo uses sn_* where facebook uses
> > > >  fb_*. Each container will need to provide a way of determining if
> the
> > > >  request is for them. Once a session is active, the stored session
> will
> > > >  tell you what you need to know.
> > > >
> > > >
> > > >  >
> > > >  >
> > > >  > 3) What are magic constants?
> > > >  >
> > > >
> > > >  By magic constants, I mean strings in the API. For instance some
> > > >  methods cal session.post on "facebook.users.user_getInfo", that is
> a
> > > >  magic constant. Instead, it should be session.post(:user_get_info)
> or
> > > >  something similar. Then, the user can look up what API key it needs
> to
> > > >  use for that platform.
> > > >
> > > >
> > > >  > 4) Could you give more detail on this? "We should take every
> magic
> > > >  > constant and turn it into a call on the
> > > >  > session."
> > > >  >
> > > >
> > > >  I explained this one above.
> > > >
> > > >  Mike
> > > >
> > > >
> > > >
> > > >  > On Mon, Mar 31, 2008 at 7:02 PM, Mike Mangino
> > > >  > <mmangino at elevatedrails.com> wrote:
> > > >  >> Why not just make the constants be class methods on the session?
> > Then
> > > >  >> you just need to worry about creating the right kind of session
> and
> > > >  >> all of the other calls will magically work. Does that sound
> sane?
> > > >  >>
> > > >  >> We should take every magic constant and turn it into a call on
> the
> > > >  >> session.
> > > >  >>
> > > >  >> Mike
> > > >  >>
> > > >  >>
> > > >  >>
> > > >  >> On Mar 31, 2008, at 5:57 PM, David Clements wrote:
> > > >  >>> For Bebo, I subclassed Facebooker::Session into a BeboSession.
>  And
> > > >  >>> then monkey patched all the calls that use constants.  The ENV
> > > >  >>> approach doesn't work for Bebo since iI am running Facebook and
> > Bebo
> > > >  >>> and Web in the same app.
> > > >  >>>
> > > >  >>> I have been thinking that this could be generalized more
> possibly
> > > >  >>> into
> > > >  >>> facebooker.yml or some other YAML.  I was thinking that the
> whole
> > > >  >>> configuration could be keyed off of the api_key that gets sent
> with
> > > >  >>> the request.  That way you could actually run more than one
> > facebook
> > > >  >>> app in the same rails instance.
> > > >  >>>
> > > >  >>> How does this Ringside Networks work?  Do you assign an API
> KEY?
> > > >  >>>
> > > >  >>> Thanks,
> > > >  >>>
> > > >  >>> Dave
> > > >  >>>
> > > >  >>>
> > > >  >>> On Mar 31, 2008, at 2:53 PM, Jonathan Otto wrote:
> > > >  >>>
> > > >  >>>> Dave, since the URLs will no longer be static are you still
> using
> > > >  >>>> ruby
> > > >  >>>> constants to store the URLs? Right now I am grabbing the URL
> > > >  >>>> configuration from facebooker.yml and storing them into the
> ENV
> > > >  >>>> constant array at the end of init.rb.
> > > >  >>>>
> > > >  >>>> But this doesn't work during tests.
> > > >  >>>>
> > > >  >>>> For example in session_test.rb's setup method, I set the ENV
> array
> > > >  >>>> (like I do in init.rb) right before calling the
> > > >  >>>> Facebook::Session.create, but the Facebooker::Session class
> can't
> > > >  >>>> see
> > > >  >>>> ENV. I'm assuming there is a better way of handling this. Let
> me
> > > >  >>>> know
> > > >  >>>> if any of you have any suggestions. I'll complete the test.
> > > >  >>>>
> > > >  >>>> These are the constants I am talking about:
> > > >  >>>>
> > > >  >>>>  APPS_SERVER_BASE_URL      = ENV['APPS_SERVER_BASE_URL'] ||
> > > >  >>>> "apps.facebook.com"
> > > >  >>>>  API_SERVER_BASE_URL       = ENV['API_SERVER_BASE_URL'] ||
> > > >  >>>> "api.facebook.com"
> > > >  >>>>  API_PATH_REST             = ENV['API_PATH_REST'] || "/
> > > >  >>>> restserver.php"
> > > >  >>>>  WWW_SERVER_BASE_URL       = ENV['WWW_SERVER_BASE_URL'] ||
> > "www.facebook.com
> > > >  >>>> "
> > > >  >>>>  WWW_PATH_LOGIN            = ENV['WWW_PATH_LOGIN'] ||
> "/login.php"
> > > >  >>>>  WWW_PATH_ADD              = ENV['WWW_PATH_ADD'] || "/add.php"
> > > >  >>>>  WWW_PATH_INSTALL          = ENV['WWW_PATH_INSTALL'] || "/
> > > >  >>>> install.php"
> > > >  >>>>
> > > >  >>>> Right now that code is in session.rb. It seems the best way to
> do
> > > >  >>>> this
> > > >  >>>> is to allow people to set these parameters in the
> facebooker.yml
> > > >  >>>> optionally, and if they are not set then it defaults to
> Facebook
> > > >  >>>> addresses. I just don't know the best way to make the
> > configuration
> > > >  >>>> portable.
> > > >  >>>>
> > > >  >>>> On Mon, Mar 31, 2008 at 12:39 PM, David Clements
> > > >  >>>> <digidigo at gmail.com> wrote:
> > > >  >>>>> Can you submit this as a patch, with tests,  I have  a  bebo
> > > >  >>>>> adapter that I
> > > >  >>>>> have been working on so I can take a look and see if it fits
> in
> > > >  >>>>> with that,
> > > >  >>>>> as I have had similar issues.
> > > >  >>>>>
> > > >  >>>>> Dave
> > > >  >>>>>
> > > >  >>>>>
> > > >  >>>>>
> > > >  >>>>>
> > > >  >>>>> On Mon, Mar 31, 2008 at 11:28 AM, Jonathan Otto
> > <jonathan.otto at gmail.com
> > > >  >>>>>>
> > > >  >>>>> wrote:
> > > >  >>>>>>
> > > >  >>>>>>
> > > >  >>>>>>
> > > >  >>>>>> I am requesting that we change the paths that absolutely
> point
> > to
> > > >  >>>>>> the
> > > >  >>>>>> facebook URL.
> > > >  >>>>>>
> > > >  >>>>>> In the PHP client there is a method in the facebook.php file
> > > >  >>>>>> called
> > > >  >>>>>> get_facebook_url() so this is easy to change there.
> > > >  >>>>>>
> > > >  >>>>>> One reason for this:
> > > >  >>>>>>
> > > >  >>>>>> Ringside Networks is a drop in replacement for Facebook that
> > > >  >>>>>> can be
> > > >  >>>>>> used for localhost development and eventually an abstraction
> for
> > > >  >>>>>> most
> > > >  >>>>>> social networks - it mimics the Facebook API so the
> Facebooker
> > > >  >>>>>> client
> > > >  >>>>>> works except for the URLs pointing to the Facebook domain. I
> > have
> > > >  >>>>>> changes ready if Mike Mangino or anyone else is willing to
> > commit
> > > >  >>>>>> them.
> > > >  >>>>>>
> > > >  >>>>>> http://wiki.ringsidenetworks.org/display/ringside/Home
> > > >  >>>>>> _______________________________________________
> > > >  >>>>>> Facebooker-talk mailing list
> > > >  >>>>>> Facebooker-talk at rubyforge.org
> > > >  >>>>>> http://rubyforge.org/mailman/listinfo/facebooker-talk
> > > >  >>>>>>
> > > >  >>>>>
> > > >  >>>>>
> > > >  >>>
> > > >  >>> _______________________________________________
> > > >  >>> Facebooker-talk mailing list
> > > >  >>> Facebooker-talk at rubyforge.org
> > > >  >>> http://rubyforge.org/mailman/listinfo/facebooker-talk
> > > >  >>
> > > >  >> --
> > > >  >> Mike Mangino
> > > >  >> http://www.elevatedrails.com
> > > >  >>
> > > >  >>
> > > >  >>
> > > >  >>
> > > >
> > > >  --
> > > >  Mike Mangino
> > > >  http://www.elevatedrails.com
> > > >
> > > >
> > > >
> > > >
> > >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/facebooker-talk/attachments/20080402/03e0c9c1/attachment-0001.html 


More information about the Facebooker-talk mailing list