<?php
require_once"includes/strings.php";
require_once"php/function.php";
require_once"php/config.php";
require_once"php/app.php";
$currentFBuserid = "0";
///////FACEBOOK GET USER INFORMATION
session_start();
// Enter the app id and secret below
define('YOUR_APP_ID', '$fbAppID');
define('YOUR_APP_SECRET', '$fbAppSecret');
require_once"php/fbsdk/src/facebook.php";
$facebook = new Facebook(array(
'appId' => $fbAppID,
'secret' => $fbAppSecret,
));
$userId = $facebook->getUser();
if($userId){
$userInfo = $facebook->api('/' + $userId);
}
Okay the issue is simple about every two hours I guess the session expires on my site and the error “Fatal error: Uncaught OAuthException: Error validating access token: Session has expired at unix time 1352329200.
The current unix time is 1352330589. thrown in /home/######/public_html/php/fbsdk/src/base_facebook.php on line 1238″
I’m having an impossible time figuring out what the issue is, no matter how long I scrape this site.
BTW:(refreshing the page solves the issue)
I really need help.
Thank you!
User access tokens acquired using the client-side flow expire after two hours.
You can either extend them, or use the server-side flow – both will result in a token that’s valid for 60 days.
https://developers.facebook.com/roadmap/offline-access-removal/
(The latest version of the PHP SDK has a method called
setExtendedAccessTokenfor extending a short-lived token.)If you are using the JS SDK to do the login, then a refresh of course makes it do a new cross-domain request to Facebook, and will get a fresh short-lived access token.