PHP facebook SDK中的过期授权码 [英] Expired authorization code in PHP facebook SDK

查看:127
本文介绍了PHP facebook SDK中的过期授权码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用新的4. * facebook php SDK,我有一个问题! ;)

I am using the new 4.* facebook php SDK and I am having an issue! ;)

基本上,我尝试找到一种方法来在第一次重定向后向图表api发出请求,当用户在记录后将发送回我的网站进入facebook 。在这种情况下,我做(在我的 index.php ):

Basically I am trying to find a way to make requests to the graph api after the first redirect when the user is sent back to my site after logging in into facebook. In that case I do (in my index.php):

$h = FacebookRedirectLoginHelper("blablabla");
$request = new FacebookRequest($h->getSessionFromRedirect(), 'GET', '/me');
$me = $request->execute()->getGraphObject();

,它的工作原理很好,我可以打印有关日志用户的日期。

and it works perfectly and I can print the date about the logged user.

我的问题是,如果我重新加载(f5)页面 index.php ,那么我得到一个例外: / p>

My problem is that if I reload (f5) the page index.php then I get an exception:

Fatal error: Uncaught exception 'Facebook\FacebookAuthorizationException' with message 'This authorization code has expired.' in /home/nourdine/development/faisbuk/vendor/facebook/php-sdk-v4/src/Facebook/FacebookRequestException.php:87 

所以我的问题是:我应该在哪里得到一个新的授权码,以便即使在Facebook登录过程中没有执行的页面中,也可以通过身份验证的用户进行新的图形API调用?

So my question is: where am I supposed to get a new authorization code in order to make new graph api calls with the authenticated user even in pages that are not executed as a result o the facebook login process?

谢谢

推荐答案

您不需要新的授权码。您需要的是使用相同的会话。 $ h-> getSessionFromRedirect()返回会话。下一次你也想使用的会话。

You don't need a new authorization code. What you need is to use the same session. $h->getSessionFromRedirect() returns a session. That session you want to use next time also.

这篇关于PHP facebook SDK中的过期授权码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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