GET parameters in Facebook Canvas applications

· 197 Words

I’m developing a Facebook app at work and was stuck on an issue for a bit. This post is just a mental note, and to prevent this happening.

I spent a while trying to find the answer to this. Finding it was difficult not least because the relevant search terms weren’t very specific. Also when you’re new to an API that redefines words left right and centre, you’re not entirely sure what the API designers called various bits and pieces. So…

If you want to pass GET arguments (aka get parameters, a querystring) in the facebook canvas URL, and have them passed through to your app, you must do it as the app_data GET argument. It is then passed through in JSON encoded in Base64 URL in the POST data. This is documented here.

So the main url is:

And the decoded JSON is:

{ ... , 'app_data': 'my-app-data',  ... }

Only the app-data query string argument works. If you want multiple parameters you’ll have to encode or delimit them yourself.

As this is encoded, you’ll need to decode it to get the JSON. If you want to do this in Python, this handy snippet works.

Read more