dongma7796 2019-07-06 12:25
浏览 71

Facebook检查PHP上令牌的有效性

I did authorization with facebook in PHP for this example https://developers.facebook.com/docs/php/howto/example_facebook_login/

Facebook has test documentation https://developers.facebook.com/docs/facebook-login/testing-your-login-flow/

Take for example this "6. Someone changes the Facebook password after logging in with Facebook to your app".

To implement this, I take a token from the session and check whether the token has expired. I do this every time a user opens a page of the site.

Everything worked fine and the user left the session for example when changing the password from facebook. But now facebook has made rate limits and when I do a check for an expired token, it ends quickly.

I don't understand what I have to do with this. How do I check the validity of a token in PHP? Please help.

if(key_exists('fb_token', $_SESSION))
{
    $tokenMetadata = facebook()->getOAuth2Client()->debugToken(
        $_SESSION['fb_token']
    );

    if($tokenMetadata->getIsValid())
        return $_SESSION['fb_user_id'];

    return false;
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制