Tuesday, January 8, 2008

Passing URL variables into your facebook application

As it turns out, passing url variables into your facebook application is pretty easy.

The link you add your application external to facebook is:


You can find your api key on your application's settings in the "Developers" application. Go to "My Applications" and you should see it in the application's description. Note that this isn't the same as your application's id.

To pass variables on this string, just append "&next?var1=val1&var2=val2" etc.

I had to escape the '&' character in this string as %26.

This link will first send the user to the facebook homepage, where they'll be directed to login. After logging in they'll be given the option to add your application. If they do, they'll be directed to whatever you specified as the "post-add" url -- it's this page whose URL will be appended with whatever params you specified in the link.

Assuming your post-add page is a php page, you can then read the vars using a simple $_GET[varName];

Not difficult at all, but also not really documented in any easy to find place by Facebook themselves.

1 comment:

Aaron said...

Muchas gracias, estuve buscando esta informacion un buen rato.
Att. Aaron Narvaez.