Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook app_data

Tags:

facebook

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?

like image 264
user975044 Avatar asked Dec 27 '11 15:12

user975044


1 Answers

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.

like image 175
bool.dev Avatar answered Oct 27 '22 13:10

bool.dev