Facebook页面选项卡app_request app_data缺失 [英] Facebook Page Tab App signed_request app_data missing
问题描述
我正在开发一个Facebook 页面选项卡应用程序 - 使用Javascript SDK - 加载时,应显示Facebook发布到我的应用程序的signed_request的内容。此signed_request应包含app_data参数,该参数在URL中传递,如下所示:
I'm developing a Facebook Page Tab App - using Javascript SDK - which, on load, should show the contents of the signed_request posted by Facebook to my App. This signed_request should contain the "app_data" parameter, which is passed in the URL, like this:
http _ // www.facebook.com / pages / MyPage-Community / SOME_ID?sk = MY_APP_ID& app_data = this_is_my_data
http_//www.facebook.com/pages/MyPage-Community/SOME_ID?sk=MY_APP_ID&app_data=this_is_my_data
链接:
- MyPage-Community是一个临时粉丝专页,已发布
- SOME_ID是,我猜,页面ID
- MY_APP_ID包含由Facebook提供的应用程序ID
- app_data = this_is_my_data(我需要的)
- MyPage-Community is a temporary Fan Page, which is published
- SOME_ID is, I guess, the page ID
- MY_APP_ID contains the app ID given by Facebook
- app_data=this_is_my_data (what I need)
注意:
- 该应用本身不在开发模式,所以它是公开可用
- 我使用 localhost 来测试应用程序
- 我已经与开发者帐户进行了测试,常规帐户(设置为App Tester,因此被授权)
- The app itself is NOT in Development mode, so it's publicly available
- I'm using localhost to test the app
- I've tested with the developer account AND with a real regular account (set as App Tester, thus authorized)
现在,在应用程序代码(javascript)中,我打电话> FB.getLoginStatus(...),这给了我authResponse对象,其中包含 signedRequest 属性 - 这一个在解码时显示这些键/值对:
Now, in the app code (javascript), I'm calling FB.getLoginStatus(...), which gives me the authResponse object that contains, among other stuff, the signedRequest property - this one, when decoded, shows me these key/value pairs:
[算法] => HMAC-SHA256
[algorithm] => HMAC-SHA256
[code] => SOME_CODED_STRING
[code] => SOME_CODED_STRING
[issued_at] => 1403183583
[issued_at] => 1403183583
[user_id] => XXXXXXXXXXXXXXX(我的用户ID)
[user_id] => XXXXXXXXXXXXXXX (my user id)
如您所见,app_data 属性不存在,因为它应该是 - 因为页面也应该,但我真的不需要那个。任何想法为什么会这样发生?在任何地方找不到答案可能是因为我使用localhost?一切似乎都在工作(虽然我尝试从应用程序中喜欢页面)时收到错误。
As you can see, the app_data property is not present as it was supposed to - as page should too, but I don't really need that one. Any ideas why this is happening? Can't find an answer anywhere. Could it be because I'm using localhost? Everything else seems to be working (although I do get an error when I try to "like" the page from within the app).
谢谢!
推荐答案
我认为你对已经签名的请求发送到你的应用程序和 signedRequest
对JS SDK的 getLoginStatus
方法的响应参数 - 它们不一样,但命名相似,因为它们有类似的目的
I think you're confusing the signed request which is POST'ed to your app and the signedRequest
parameter of the response to the JS SDK's getLoginStatus
method - they're not the same thing but are named similarly because they have a similar purpose
JS SDK返回值或多或少相当于您在Facebook画布应用程序上收到的值,但它不是相同的数据或传送机制来源,并且不会有相同的字段
The JS SDK returns values more or less equivalent to what you receive on a Facebook canvas app, but it's not the same source of data or delivery mechanism, and won't have the same fields
要使用页面
和 app_data
读取实际签名的请求,你需要做服务器端 - 这里的说明: https://developers.facebook.com/docs/facebook-login/using-login-with-games#checklogin
(它适用于页面标签应用程序以及canva s应用)
To read the actual signed request with the page
and app_data
, you need to do it server side - instructions for which are here: https://developers.facebook.com/docs/facebook-login/using-login-with-games#checklogin
(It applies to page tab apps as well as canvas app)
这篇关于Facebook页面选项卡app_request app_data缺失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!