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