Situation with signed_request, sessions and PHP SDK 3.0

浪子不回头ぞ 提交于 2019-12-11 06:09:30

问题


I am making an application and on the "front" page of the Tab I get the signed_request. But when I navigate to different pages on the app it stops providing the data.

So far this work:

$signed_request = $facebook->getSignedRequest();<br />
$user_profile = $facebook->api('/me');<br />
echo $user_profile['id'];<br />
echo $user_profile['name'];
echo $_SESSION['signed_request']; // Returns the data

But when I navigate to other pages, it doesn't give anything. It looses everything. How can I keep the data from the signed_request? Do I need to use sessions in some way?


回答1:


I've found that the signed request isn't always passed to each page, so I used the following to hold that myself in the session object. I set this on the login page before I redirect to other pages in my app:

if (!isset($_SESSION["SR"]))
    $_SESSION["SR"] = $_REQUEST["signed_request"];

$signed_request = $_SESSION["SR"];

Hope that helps.



来源:https://stackoverflow.com/questions/8229986/situation-with-signed-request-sessions-and-php-sdk-3-0

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