<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -6,32 +6,32 @@ and passes it to the app as a POST with the fb_sig_* params added, etc. Returns
 with FBML parsed (sort of) and some chrome added.
 
 To use, run 'fakebook' from the command line to start up a Fakebook proxy. For example, if you 
-have an app running on port 3000, and the callback path is &quot;/facebook/&quot;, and the canvas path 
+have an app running on port 3000, and the callback path is &quot;/&quot;, and the canvas path 
 is &quot;myapp&quot;, you'd run:
 
-  $ fakebook --callback &quot;http://localhost:3000/facebook/&quot; --canvas &quot;/myapp/&quot;
+  $ fakebook --callback &quot;http://localhost:3000/&quot; --canvas &quot;myapp&quot;
 
 Fakebook will look for a config file at &quot;./config/fakebook.yml&quot;, so you can put one in your 
 project and save some typing. The file should look like this:
 
-  callback: &quot;http://localhost:3000/callback-path/&quot;
-  canvas:   &quot;/canvas-path/&quot;
-  secret:   345345jk4jkhfpo2390s
-  user:     123435567
-  session:  345345jk4jkhfpo2390s
-  friends:  &quot;10,11,12&quot;
+  callback: &quot;http://localhost:3000/&quot;
+  canvas:   myapp
+  secret:   secret
+  user:     1
+  session:  session_key
+  friends:  &quot;2, 3, 4&quot;
   host:     0.0.0.0
-  port:     6000
+  port:     5000
 
 See &quot;fakebook --help&quot; for more options.
 
 You can also use the library directly with the Fakebook class:
 
   require 'fakebook'
-	app = Fakebook.new :callback  =&gt; &quot;http://localhost:3000/callback-path/&quot;,
-	                   :canvas    =&gt; &quot;/myapp/&quot;,
-	                   :secret    =&gt; &quot;app-secret&quot;,
-	                   :fb_params =&gt; { :user =&gt; 123, :session_key =&gt; 'abc', :friends =&gt; &quot;345,456&quot; }
+	app = Fakebook.new :callback  =&gt; &quot;http://localhost:3000/&quot;,
+	                   :canvas    =&gt; &quot;myapp&quot;,
+	                   :secret    =&gt; &quot;secret&quot;,
+	                   :fb_params =&gt; { :user =&gt; 1, :session_key =&gt; 'session_key', :friends =&gt; [2, 3, 4] }
 	app.request(&quot;/&quot;)
 
 Because Fakebook implements #call according to the Rack specification[1], you can create an </diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,7 @@ rescue LoadError =&gt; e
   server = Rack::Handler::WEBrick
 end
 rack_options = { :Port =&gt; 5000, :Host =&gt; &quot;0.0.0.0&quot; }
-fakebook_options = { :callback =&gt; &quot;http://0.0.0.0:3000/facebook/&quot;, :canvas =&gt; &quot;/myapp/&quot;, :secret =&gt; &quot;app-secret&quot;, :fb_params =&gt; { :user =&gt; 123, :session_key =&gt; 'session-key', :friends =&gt; &quot;2,3,4&quot; } }
+fakebook_options = { :callback =&gt; &quot;http://0.0.0.0:3000/&quot;, :canvas =&gt; &quot;myapp&quot;, :secret =&gt; &quot;secret&quot;, :fb_params =&gt; { :user =&gt; 1, :session_key =&gt; 'session_key', :friends =&gt; [2, 3, 4] } }
 config_file = &quot;config/fakebook.yml&quot;
 
 OptionParser.new do |opts|
@@ -91,7 +91,7 @@ app = Rack::Builder.new {
   run fakebook
 }
 
-STDERR.puts &quot;Starting Fakebook proxy from http://#{rack_options[:Host]}:#{rack_options[:Port]}#{fakebook.canvas} to #{fakebook.callback}&quot;
+STDERR.puts &quot;Starting Fakebook proxy from http://#{rack_options[:Host]}:#{rack_options[:Port]}/#{fakebook.canvas}/ to #{fakebook.callback}&quot;
 STDERR.puts &quot;  Using fb_params: #{fakebook.fb_params.inspect}&quot;
 
 server.run app, rack_options</diff>
      <filename>bin/fakebook</filename>
    </modified>
    <modified>
      <diff>@@ -5,26 +5,26 @@ require 'erb'
 require 'rubygems'
 require 'rack'
 
-# Valid options: 
-#   :callback
-#   :canvas
-#   :secret
-#   :fb_params
-#   :template
-#
 class Fakebook
   
   Version = '0.1.0'
   
   attr_accessor :callback, :canvas, :secret, :fb_params, :template
 
+  # Options: 
+  #   :callback
+  #   :canvas
+  #   :secret
+  #   :fb_params
+  #   :template
+  #
   def initialize(options = {})
-    @callback  =  options[:callback]
-    @canvas    =  options[:canvas]
-    @secret    =  options[:secret]
-    @fb_params = (options[:fb_params] || {}).merge(:in_canvas =&gt; 1, :expires =&gt; 0, :added =&gt; 1)
-    @template  =  options[:template] || File.join(File.dirname(__FILE__), &quot;templates&quot;, &quot;standard.html.erb&quot;)
-    @static    =  Rack::File.new File.join(File.expand_path(File.dirname(__FILE__)), &quot;..&quot;, &quot;lib&quot;)
+    @callback  =  options[:callback]  || &quot;http://localhost:3000/&quot;
+    @canvas    =  options[:canvas]    || &quot;myapp&quot;
+    @secret    =  options[:secret]    || &quot;secret&quot;
+    @fb_params = (options[:fb_params] || { :user =&gt; 1, :session_key =&gt; &quot;session_key&quot;, :friends =&gt; [2, 3, 4] }).merge(:in_canvas =&gt; 1, :expires =&gt; 0, :added =&gt; 1)
+    @template  =  options[:template]  || File.join(File.dirname(__FILE__), &quot;templates&quot;, &quot;standard.html.erb&quot;)
+    @static    =  Rack::File.new(File.expand_path(File.dirname(__FILE__)))
   end
 
   # Implements the Rack interface. Takes a hash representing the environment; returns an 
@@ -34,8 +34,8 @@ class Fakebook
     res = Rack::Response.new
     path = env['PATH_INFO']
 
-    if File.file?(File.join(@static.root, Rack::Utils.unescape(path)))
-      @static.call(env)
+    if File.exists?(File.join(@static.root, Rack::Utils.unescape(path)))
+      return @static.call(env)
     elsif path=='/fakebook-rest-server'
       res[&quot;Content-Type&quot;] = &quot;text/json; charset=utf-8&quot;
       res.write %Q({ &quot;success&quot;:&quot;true&quot; })
@@ -56,7 +56,7 @@ class Fakebook
   
   # Takes a path and optional params; returns the response body.
   def request(path, params={})
-    url = URI.parse(@callback + path.gsub(Regexp.new('^' + @canvas), ''))
+    url = URI.parse(@callback + path.gsub(Regexp.new('^/' + @canvas + '/'), ''))
     path_and_query_string = &quot;#{url.path}?#{url.query}&quot;
     request_body = sign(params).map{ |a| &quot;#{a.first}=#{a.last}&quot; }.join('&amp;')
     response = Net::HTTP.new(url.host, url.port).post(path_and_query_string, request_body)
@@ -64,14 +64,21 @@ class Fakebook
   end
 
   private
-  
+    
     def sign(params)
-      params_to_sign = (@fb_params || {}).merge(:time =&gt; Time.now.to_f)
+      params_to_sign = normalize(@fb_params || {}).merge(:time =&gt; Time.now.to_f)
       raw_string = params_to_sign.map{ |pair| pair.join('=') }.sort.join + @secret
       signature = Digest::MD5.hexdigest(raw_string)
       params_to_sign.each { |k,v| params[&quot;fb_sig_&quot; + k.to_s] = v.to_s }
       params['fb_sig'] = signature
-      params
+      normalize(params)
+    end
+
+    def normalize(params)
+      params.inject({}) do |hash, pair|
+        hash[pair[0].to_s] = pair[1].is_a?(Array) ? pair[1].join(',') : pair[1].to_s
+        hash
+      end
     end
 
     def parse_fbml(body)</diff>
      <filename>lib/fakebook.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>198bed4661b688162512041c24605f513e210cdd</id>
    </parent>
  </parents>
  <author>
    <name>Scott Raymond</name>
    <email>sco@scottraymond.net</email>
  </author>
  <url>http://github.com/collectiveidea/fakebook/commit/bd14c182dcc5eb76f9c5b12cd4481c58bccb803d</url>
  <id>bd14c182dcc5eb76f9c5b12cd4481c58bccb803d</id>
  <committed-date>2008-04-09T10:08:25-07:00</committed-date>
  <authored-date>2008-04-09T10:08:25-07:00</authored-date>
  <message>improving static file handling, and changing some defaults</message>
  <tree>621b14fbe63fa3c6154cec7a3930f1153b821427</tree>
  <committer>
    <name>Scott Raymond</name>
    <email>sco@scottraymond.net</email>
  </committer>
</commit>
