I am developing a facebook fbml app on google app engine using pyfacebook library. I was facing a weird problem. If the user was accessing the app for the first time, I used to redirect him to the application installation page and facebook used to say installation url is invalid. But, if the same redirected url was copy pasted in browser’s window, it used to take the user to the installation page. Weird.

The following was my code to do this:

        if fb.check_session(self.request) and fb.added:
           url = fb.get_add_url()

I tried searching in google and facebook forums for this issue but came up with zilch. So, as a work around, I figured out this quick hack:

        template_values = {}

        if fb.check_session(self.request) and fb.added:
           template_values['installation_url'] = fb.get_add_url()

Relevant fbml code:

    This is my app.
      <fb:redirect url="{{installation_url}}" />

What I am doing here is, first I am checking if the user has already added the app. If so, display the app, else, redirect him to the app installation page.

This is a dirty hack but, until I figure out what was wrong with the original one this will have to do :(.