使用 Ruby/sinatra/frankie/facebooker 在 Facebook 上出现身份验证问题

发布于 2024-08-25 18:02:24 字数 2958 浏览 7 评论 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 在第一个和第三个具有相同的值?

干杯和感谢, 泽玛丽亚

I'm using sinatra/frankie/facebooker to prototype something simple to test the facebook api, i'm using mmangino-facebooker the more recent version from github and I cloned the most recent version of frankie. I'm using sinatra 0.9.6.

My main code is as simple as possible:

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

The index page just renders a link to the other one (identified by regex "/:uid/:image") however I always get an error when it's trying to render the one identified by regex "/: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'

I've no idea why, it seems to be related with the auth token I guess..

I logged the request made o the fb rest server:

{: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"}

The last one gives the error, it could be related with auth_token having the same value in the 1st and on the 3rd ?

Cheers and tks,
Ze Maria

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北方的巷 2024-09-01 18:02:24

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

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 '/'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文