Adg*_*aza 5

您最初在signed_request中从Facebook收到的令牌将在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 
Run Code Online (Sandbox Code Playgroud)

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

if (response.user.sources.FACEBOOK.expires > new Date().getTime() ) {
    //do something
}
Run Code Online (Sandbox Code Playgroud)