[Ruby on Rails] How to Redirect Facebook External Access to Facebook Page App
In Ruby on Rails, I implemented a process to redirect external access (outside Facebook) to the Facebook page app.
before_filter :check_access_from_facebook
def check_access_from_facebook
redirect_to MyRailsApp::Application.config.facebook_app_url if params[:signed_request].nil?
end
Facebook apps always have the signed_request parameter in the request when accessed from within Facebook.
So when this parameter is missing, I determined it was external access (outside Facebook) and implemented a redirect to the Facebook page app.
When implementations depend on parameters retrieved from signed_request, the app won’t function properly as a standalone web application outside Facebook. This time, I solved this by implementing a redirect.
That’s all from the Gemba regarding Facebook app redirect handling.
【References】
・Railsのcontrollerやviewの中で現在処理中のURLを知る方法: request.url - memo.yomukaku.net