Routing to the initial action after facebook application install

Some facebook applications might have multiple entries. For example, a user might be adding an application (action – new) or replying to an invitation (action – reply, param – id). Since the UI for Facebook application configuration allows to provide only static Post-Add URL it might seem like there is no way to route users back to the original action if they tried to reach when the application has not been installed for them. Luckily, we have full control on the destination via the next paramater of the post install URL. All we need is to build a URL using the incoming call parameters with the exclusion of Facebook-specific ones.

This is an example for Facebook on Rails based code that might go to the application controller:

class ApplicationController < Facebook::FBMLController

protected

  before_filter :require_facebook_install

  def require_facebook_install
    if in_canvas? && !fbsession.is_valid?
      redirect_to fbsession.get_install_url(:next => url_for(post_install_params))
      false
    end
  end

  def post_install_params
    params.merge(:init => true).delete_if { |k, v| k.starts_with?('fb_sig') }
  end

end

Notice that the code sets the init parameter so it can be used to identify a post install call

3 Comments

  1. Farmvillebot says:

    FarmVille Bot This Bot does everything for you. such as, plowing, planting, harvesting, all animals and trees. Also does some sweet missions that get you money, Levels your farm really fast. I Went from lvl 27-60 in about a week and a half.http://www.envirofile.org/download/33857

  2. Arnwine says:

    Is there any cheater programs for facebook games? Im lookin for cheater programs for Tower Blocks and Crazy Taxi. Is there any programs out there that I can use for facebook games? (Mindjolt Games)

Leave a Reply