Cannot access Facebook signed_request with an iframe tab

倖福魔咒の 提交于 2019-12-21 06:15:06

问题


I've got an iframe loading in a facebook tab on a fan page and I'm not having any luck accessing the $_REQUEST["signed_request"] object. I'm confused because this is supposed to be a freebie and easily accessible. I've read and re-read the facebook docs and rechecked my facebook application settings but nothing is working.

isset($_REQUEST['signed_request']

is always false. Since I'm using the Facebook PHP sdk I've also tried

$facebook->getSignedRequest();

I've done print_r on the $_REQUEST and I don't see the signed_request in there. When I print_f the $facebook object, I see that the signedRequest is empty

[appId:protected] => XXX
[apiSecret:protected] => XXXXXXXXXXXXXXXXXXXX
[session:protected] => Array

        [access_token] => XXXXXXXXXX|2.h75WqKxcA1xbNPufFvpKQQ__.3600.1304452800.1-726960374|JiO0ZS30SyLaApeqhMtdocK8B_Y
        [base_domain] => XXXXXXXXX
        [expires] => 1304452800
        [secret] => rDF9C_z43_EUFy0Q_e6tyQ__
        [session_key] => 2.h75WqKxcA1xbNPufFvpKQQ__.3600.1304452800.1-726960374
        [sig] => 1971ef7eb8057c7404eae1f82d770ab5
        [uid] => XXXXXXXXXXXXXXX


[signedRequest:protected] => 
[sessionLoaded:protected] => 1
[cookieSupport:protected] => 1
[baseDomain:protected] => 
[fileUploadSupport:protected] => 

[EDIT] I do have the OAuth 2.0 setting enabled for the application.


回答1:


OK, just had this on problem myself and found the issue.

Make sure that you do not have a 301 redirect on the canvas or tab page. In my case I set the app up as "mydomain.com/facebook/tab/" but my site was doing a 301 to "www.mydomain.com/facebook/tab/"

The content would show, bit the 301 caused the signedRequest to be null.

Added "www" to my domain in the app settings and the signedRequest now contains the data I was looking for.




回答2:


I just had this problem. Finally figured it out. I had to add a forward slash to the end of my Tab URLs in the application settings on the Basic tab.

Instead of: http://domain.com/facebook

I needed: http://domain.com/facebook/




回答3:


I had the same problem And I resolve it. It's a problem with the URLS. Be sure that your App Domain & Page Tab URL match the same domain for example:

1) App domain: example.com Page Tab URL: example.com will work

2) App domain: example.com Page Tab URL: example.com/app/ will work

3) App domain: fb.example.com Page Tab URL: fb.example.com/app/ will work

4) App domain: fb.example.com Page Tab URL: example.com/fb will not work




回答4:


After some investigation, I suspect this has something to do with where the iframe source is hosted.

When I moved everything to localhost, the signed_request started coming in fine.




回答5:


Edit the settings of your tab application. On "Advanced" tab, make sure "OAuth 2.0 for Canvas" is enabled.




回答6:


it's an old question but I found this with google... the problem for me was that I did a manual redirect to the https url of my pagetab and than the $_POST['signed_request'] got lost



来源:https://stackoverflow.com/questions/5874323/cannot-access-facebook-signed-request-with-an-iframe-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!