[英]How to implement Sessions in a Facebook Multi-pages canvas application (php sdk 4.0)
Here is my question: Im trying to create a Facebook Canvas Application with PHP sdk 4.0 and im lost in all the confusing documentations... I don't understand how the login process is working with multiple pages application. 这是我的问题:我试图用PHP sdk 4.0创建一个Facebook Canvas应用程序,而我却迷失在所有混乱的文档中……我不明白登录过程如何与多页应用程序一起工作。 Can someone help me please?
有人能帮助我吗?
I put this code on the landing page of the app and that works fine: 我将此代码放在应用程序的登录页面上,效果很好:
FacebookSession::setDefaultApplication( 'app_id', 'app_secret' );
$helper = new FacebookCanvasLoginHelper();
try {
$session = $helper->getSession();
} catch (FacebookRequestException $ex) {}
the question is: what should i do on the second page? 问题是:我应该在第二页上做什么? _Write the same code?
_写相同的代码? _Save the Facebook session in $_SESSION in order to use it on the other pages?
_将Facebook会话保存在$ _SESSION中,以便在其他页面上使用它? _Save only the token to retreive the session?
_只保存令牌以恢复会话?
I walked the web for 2 days to find the answer with no result.. I found Facebook documentation is not very clear 我在网上走了两天,没有找到答案。.我发现Facebook文档不是很清楚
Thx to you a lot! 非常感谢您! ;)
;)
You need to set the session / access_token and save it to a PHP Session, eg 您需要设置会话/ access_token并将其保存到PHP会话,例如
$_SESSION['access_token'] = $session->getToken();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.