Facebook app_data [英] Facebook app_data
问题描述
http://developers.facebook.com/docs/authentication/signed_request/
文档含糊不清。我不知道如何实际使用app_data字段。我想要将应用数据添加到页面时将其应用程序传递给应用程序,以便其上显示的内容与Facebook页面相关。
例如,我想要在我的网站上的用户个人资料仅显示在该用户的Facebook页面上。为此,当用户将应用添加到其页面时,我想将用户ID发送到fb签名请求。然后随时访问页面,我将拉出应用程序数据并运行一些php显示正确的配置文件。
我可以用app_data这样做还是不可能?
从您引用的文档
应用数据
包含查询字符串参数内容的JSON字符串也称为app_data。 通常在应用程序构建链接以将某些数据传递给自身时指定。仅在您的应用程序是加载在页面选项卡中的iframe时才可用。
所以,当你的应用程序生成了 时,应用数据是有用的,某些用户将点击并在某些Facebook上点击您的应用
如果用户直接访问某个页面(和应用标签),那么您将无法获取app_data字段。
一旦用户在任何一个页面上安装了您的应用程序(并给出了您的应用程序最低权限),您总是拥有 page_id
和 user_id
在Facebook将发送到您的应用程序的 signed_request
中的字段,无论是在画布应用程序(否 page_id
字段)和页面标签应用程序。
对于您想要做的,您只需阅读 signed_request
,然后找出 page_id
并相应地显示数据,甚至不需要使用user_id。
希望这回答您的问题。如果需要,请要求澄清。
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?
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.
这篇关于Facebook app_data的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!