Question:

My application will publish on user's wall and the link provided in the post is something like http://apps.facebook.com/myapp/?def=yes&id=330,

When I click on this link from the user's wall, I expect params in the query string "?def=yes&id=330" will be passed to my application. However I find that the parameters are replaced by Facebook's session params like : session={"session_key"= ........}.

I think there is a kind of session expiration or something similar because if I click the link for the second time, my application can get the params correctly.

What is happening? And how should I pass these params via link posted in the user's wall?

 

 

Answer:

Appreciate if you can like this page if you find it useful! - Click "Like"

The problem is probably caused by the "redirect" login in the application.

When the user clicks on the link, the GET parameters are passed to the application. But at that time, if the session is not valid (which is usually the case for user clicking the link posted in user's wall) and you get logic in your application to redirect user to the "loginUrl", then a redirect will be formed and the GET parameter will be lost "by default".

To retain these GET parameter, you can include the current GET parameters and append those you are interested in to the "next" url so that after building the session, when FB redirect you back to the app (i.e. the next url), you can get the params.

If you are not sure about what is the "next" url that I am talking about, kindly refer to my faq When there is no valid session exists, what should I do?

 

The same scenario may happen when a user post a form in your application page. However, in such case, the session should be already there. I just notice that there are cases where some hosting company's server cannot retain the Facebook session when user post a form in the application. Similar handling should able to solve the problem. However, it would still the best to find out with your hosting why this happens. (For this point, it is my sharing only... I never encounter this in my own hosting and my server in joyent.com.)

 

 

Find my FAQ on Facebook Development useful? Download the PDF for all the FAQs HERE!