Signed_request,会话和PHP SDK 3.0的情况 [英] Situation with signed_request, sessions and PHP SDK 3.0

查看:80
本文介绍了Signed_request,会话和PHP SDK 3.0的情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个应用程序,并且在选项卡的首页"页面上获得了signed_request.但是,当我导航到应用程序上的不同页面时,它将停止提供数据.

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

但是当我导航到其他页面时,它什么也没有. 它失去了一切.我该如何保留signed_request中的数据?我需要以某种方式使用会话吗?

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?

推荐答案

我发现签名的请求并不总是传递到每个页面,因此我使用以下内容将自己保存在会话对象中.我在登录页面上进行了设置,然后重定向到应用程序中的其他页面:

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"];

希望有帮助.

这篇关于Signed_request,会话和PHP SDK 3.0的情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆