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

Jonathan Otto jonathan.otto at gmail.com
Tue Apr 1 17:24:34 EDT 2008


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
>
>
>
>


More information about the Facebooker-talk mailing list