0

我正在使用 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'

我不知道为什么,它似乎与我猜的身份验证令牌有关..

我记录了从 fb 休息服务器发出的请求:

{: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 日具有相同的值有关?

干杯和 tks,泽玛丽亚

4

1 回答 1

0

Apparently if you are using iFrame, you can get the auth tken, however using FBML, facebook sends it overs as a post parameter, so you have to use post '/' as your index, not get '/'.

于 2010-08-30T16:02:59.363 回答