我正在开发一个facebook应用程序。我使用会话与cookie,它都工作得很好。突然,IE8在cookie上出现了一些错误。它阻止了我的网站,因为它在iframe中。所以我开始了解P3P Header。我正确地使用了它,问题解决了。但是客户现在希望我使用GET,如果cookie不可用。我这样做,但现在我面临的问题,facebook PHP Sdk在其会话有问题。它的getSession方法不是获取会话和重定向来验证用户,然后重定向回应用程序。但在所有这些中,它失去了GET变量PHPSESSID。下面是stackoverflow的一个线程,它有一些类似的东西,所以可能对你们有帮助。Facebook PHP SDK getSession()获取session失败。饼干问题?
如果cookie不可用,这是用于GET会话的代码:
ini_set( 'session.use_cookies_only', false );
ini_set( 'session.use_trans_sid', true );
session_start();
是访问fb的代码。:
$facebook = new Facebook(array(
'appId' => FACEBOOK_APPID,
'secret' => FACEBOOK_SECRET,
'cookie' => true,
));
$this->facebook=$facebook;
// We may or may not have this data based on a $_GET or $_COOKIE based session.
// If we get a session here, it means we found a correctly signed session using
// the Application Secret only Facebook and the Application know. We dont know
// if it is still valid until we make an API call using the session. A session
// can become invalid if it has already expired (should not be getting the
// session back in this case) or if the user logged out of Facebook.
$this->session = $facebook->getSession();
如果你能给我任何提示,请告诉我。
感谢大家
这似乎是facebook API的一个永远不会结束的问题。在这种情况下,会话功能会随机中断,你可以对此做很多事情。我通常在我的应用程序中做的是禁用cookie并将facebook会话存储在我自己的应用程序session中。每个请求都有一个父控制器,它负责检查SESSION。如果找到一个有效的SESSION,它将被设置为facebook的SESSION对象。这确保在调用getSession()时返回一个有效的会话。