使用Ruby / sinatra / frankie / facebooker在Facebook上验证问题

时间:2010-03-19 13:18:50

标签: ruby sinatra facebooker auth-token

我正在使用sinatra / frankie / facebooker来制作一些简单的原型来测试facebook api,我正在使用mmangino-facebooker来自github的最新版本,我克隆了最新版本的frankie。我正在使用sinatra 0.9.6。

我的主要代码尽可能简单:

before do

  ensure_application_is_installed_by_facebook_user
  @user = session[:facebook_session].user
  @photos = session[:facebook_session].get_photos(nil,@user.uid,nil)
end

get "/" do
erb :index
end

get "/:uid/:image" do |uid,image|


  @photo_selected = session[:facebook_session].get_photos([image.to_i],nil,nil)


  erb :selected


end

索引页面只是呈现另一个链接(由正则表达式“/:uid /:image”标识)但是当我尝试渲染由正则表达式标识的那个时,我总是会收到错误“/:uid /:image “

Facebooker::Session::MissingOrInvalidParameter: Invalid parameter

    /Library/Ruby/Gems/1.8/gems/mmangino-facebooker-1.0.50/lib/facebooker/parser.rb:610:in `process'
    /Library/Ruby/Gems/1.8/gems/mmangino-facebooker-1.0.50/lib/facebooker/parser.rb:30:in `parse'
    /Library/Ruby/Gems/1.8/gems/mmangino-facebooker-1.0.50/lib/facebooker/service.rb:67:in `post'
    /Library/Ruby/Gems/1.8/gems/mmangino-facebooker-1.0.50/lib/facebooker/session.rb:600:in `post_without_logging'
    /Library/Ruby/Gems/1.8/gems/mmangino-facebooker-1.0.50/lib/facebooker/session.rb:611:in `post'
    /Library/Ruby/Gems/1.8/gems/mmangino-facebooker-1.0.50/lib/facebooker/logging.rb:20:in `log_fb_api'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
    /Library/Ruby/Gems/1.8/gems/mmangino-facebooker-1.0.50/lib/facebooker/logging.rb:20:in `log_fb_api'
    /Library/Ruby/Gems/1.8/gems/mmangino-facebooker-1.0.50/lib/facebooker/session.rb:610:in `post'
    /Library/Ruby/Gems/1.8/gems/mmangino-facebooker-1.0.50/lib/facebooker/session.rb:198:in `secure!'
    ./config/frankie/lib/frankie.rb:66:in `secure_with_token!'
    ./config/frankie/lib/frankie.rb:44:in `set_facebook_session'
    ./config/frankie/lib/frankie.rb:164:in `ensure_authenticated_to_facebook'
    ./config/frankie/lib/frankie.rb:169:in `ensure_application_is_installed_by_facebook_user'

我不知道为什么,它似乎与我认为的auth令牌有关..

我记录了fb rest服务器发出的请求:

{:sig=>"4f244d1f510498f4efaae3c03d036a85", :generate_session_secret=>"0", :method=>"facebook.auth.getSession", :auth_token=>"9dae0d02c19c680b574c78d202b0582a", :api_key=>"70c14732815ace0ae71a561ea5eb38b7", :v=>"1.0"}

 {:call_id=>"1269003766.05665", :sig=>"194469457d1424dc8ba0678979692363", :method=>"facebook.photos.get", :subj_id=>750401957, :session_key=>"2.lXL0z3s4_r573xzQwAiA9A__.3600.1269010800-750401957", :api_key=>"70c14732815ace0ae71a561ea5eb38b7", :v=>"1.0"}


{:sig=>"4f244d1f510498f4efaae3c03d036a85", :generate_session_secret=>"0", :method=>"facebook.auth.getSession", :auth_token=>"9dae0d02c19c680b574c78d202b0582a", :api_key=>"70c14732815ace0ae71a561ea5eb38b7", :v=>"1.0"}

最后一个给出了错误,它可能与auth_token有关,在第1和第3个时具有相同的值?

干杯和丁字裤, 泽玛丽亚

1 个答案:

答案 0 :(得分:0)

显然如果你使用iFrame,你可以获得身份验证令牌,但是使用FBML,facebook会将其作为post参数发送,因此你必须使用post'/'作为索引,而不是'/'。