facebook访问令牌的到期时间 [英] Expiry Time of facebook access token

查看:322
本文介绍了facebook访问令牌的到期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

p>您最初从Facebook收到的 signed_request 中的令牌将在2小时或7200000之内到期毫秒或7200秒。如果您使用以下请求扩展令牌,则在响应中将收到一个新的到期时间5184000秒,转换为60天。我通常所做的是将这个时间以毫秒为单位存储到当前Unix时间(从时间开始以毫秒为单位),并在需要时持续检查该时间。



扩展令牌

  https://graph.facebook.com/oauth/access_token? 
client_id = APP_ID&
client_secret = APP_SECRET&
grant_type = fb_exchange_token&
fb_exchange_token = EXISTING_ACCESS_TOKEN

作为一个例子,我会请求客户端的源信息,请执行以下检查..

  if(response.user.sources.FACEBOOK.expires> new Date()。getTime )){
//做某事
}


How do I find at what time an access token is going to expire in php?

解决方案

The token you receive initially from Facebook in the signed_request expires in 2 hours or 7200000 milliseconds or 7200 seconds. If you extend the token with the below request you will receive a new expire time of 5184000 seconds in the response which converts to 60 days. What I typically do is store this time in milliseconds added to the current Unix time in milliseconds since the epoch and continually check against that time when needed.

Extending the token:

https://graph.facebook.com/oauth/access_token?             
    client_id=APP_ID&
    client_secret=APP_SECRET&
    grant_type=fb_exchange_token&
    fb_exchange_token=EXISTING_ACCESS_TOKEN 

As an example I would request that sources information on the client side and do the following check..

if (response.user.sources.FACEBOOK.expires > new Date().getTime() ) {
    //do something
}

这篇关于facebook访问令牌的到期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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