Hi there,<br><br>I&#39;m interested in building Facebook applications with Seaside.&nbsp; I&#39;m new to Seaside and would like some advice on how to implement the logic.&nbsp; There are basically two needs within a Facebook application:&nbsp; first, receive the Facebook specific variables from the request and provide access to the underlying application, and second, provide a REST-client interface so that you can query Facebook for information about the user and their friends.&nbsp; The second item is not so challenging as it is not much more than a web client connecting.&nbsp;&nbsp; The first item is a little challenging to me as Seaside offers to do much of the heavy work for you in processing variables during a request which I could do special processing under different frameworks.<br>
<br>A Facebook application is very simple:&nbsp; you configure your application to work through the Facebook &quot;proxy&quot;.&nbsp; So, a Facebook app might look like <a href="http://apps.facebook.com/myapplication">http://apps.facebook.com/myapplication</a>.&nbsp; When the Facebook appserver sees a request for &quot;myapplication&quot; it makes a request to <a href="http://myapplicationserver.com/foobar">http://myapplicationserver.com/foobar</a> which is my server.&nbsp; Facebook makes a POST to this URL with a few extra variables than would normally be expected in the request, variables which are all prefaced with &quot;fb_sig_&quot;, like &quot;fb_sig_user&quot;.&nbsp; One of the variables (&quot;fb_sig&quot;) is a signed digest of the variables concatenated together.&nbsp; To validate the request (ensure it comes from Facebook) you need to grab all &quot;fb_sig_*&quot; variables, sort them, and then use a secret key to generate the digest, a secret key which only your application and Facebook are aware of.&nbsp; If the signature sent in the request and the one you generate match, then you know the data is trusted.&nbsp; Then your application can trust that among other things the user_id sent is valid and the request did come from a user accessing your application through Facebook.<br>
<br>I&#39;d like to write logic to enable this for my Seaside applications.&nbsp; Can someone tell me how I go about overriding the proper classes in the request chain to <br>process these variables and then provide accessors within my base classes to the Facebook data?&nbsp; <br>
<br>Here is the logic for processing the request in Ruby:<br><br>def self.verify_fb_signature( params, sig )<br>&nbsp;&nbsp;&nbsp; signature = &quot;&quot;<br>&nbsp;&nbsp;&nbsp; keys = params.keys.sort<br>&nbsp;&nbsp;&nbsp; keys.each do |key|<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; next if key == &#39;fb_sig&#39;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; next unless key.include?(&#39;fb_sig&#39;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; key_name = key.gsub(&#39;fb_sig_&#39;, &#39;&#39;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; signature += key_name<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; signature += &#39;=&#39;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; signature += params[key]<br>&nbsp;&nbsp;&nbsp; end<br>
&nbsp;&nbsp;&nbsp; signature += ENV[ &#39;FACEBOOK_SECRET_KEY&#39; ] # example:&nbsp; &#39;aabddasasasweasdsdaqewasdasd&#39;<br>&nbsp;&nbsp;&nbsp; calculated_sig = Digest::MD5.hexdigest(signature)<br>&nbsp;&nbsp;&nbsp; calculated_sig.eql? sig<br>&nbsp; end<br><br>Thanks,<br>Chris<br>