11

Can someone explain to me how to use facebook app_data which is part of the signed request?

http://developers.facebook.com/docs/authentication/signed_request/

The documentation is vague. I can't figure out how to actually use the app_data field. I want to be able to pass the app data to the app when it is added to a page so that the content displayed on it is relevant to the Facebook page.

for example I want a user profile on my site to only be displayed on that users facebook page. To do so I want to send the user ID to the fb signed request when the user adds the app to their page. Then anytime the page is visited I will pull the app data and run some php to display the correct profile.

Can I do this with the app_data or is this not possible?

1
  • 1
    +1 good question. You can also comment now, ask for clarifications to my answer if required.
    – bool.dev
    Dec 27, 2011 at 17:47

1 Answer 1

10

From the documentation that you have cited

App Data is

A JSON string containing the content of a query string parameter also called app_data. Usually specified when the application built the link to pass some data to itself. Only available if your app is an iframe loaded in a Page tab.

So app data is useful only when your application has generated a link that some user will click and follow through to your app on some Facebook page.

And if a user is visiting some page (and the app tab) directly, then you won't get the app_data field.

Once a user has installed your app (and has given your app minimum permissions) on any one of their pages, you always have the page_id and user_id fields in the signed_request that Facebook will send to your app, both in canvas apps (no page_id field) and page tab apps.

For what you want to do, you can just read the signed_request and then find out the page_id and display data accordingly, you do not even have to use user_id.

Hope this answers your question. Do ask for clarifications, if required.

2
  • 1
    thanks, I guess I'll have to just use the page id then. I needed to establish a relationship between my content and the facebook page and was hoping I could feed the app installed on that page with the app_data per a link I would provide for each user with the app_data appended.
    – user975044
    Dec 27, 2011 at 21:11
  • you are welcome, you just need to store your data with respect to page_ids, so you have relationship between page_id (Facebook page) and content . Nothing to get worried about.
    – bool.dev
    Dec 28, 2011 at 4:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.