Having problem with facebook api OAuth...
OAuthException: An active access token must be used to query information about the current user.loggain
the thing is that the first time it work perfect but after 3 tries it's giving me the error...
user can borrow a tool for free from the store and user can borrow up to 4 tools.. after every time user compeletes the steps i refresh the page and after 3-4 refresh i get the error
<?php
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
require 'php/facebook.php';
require 'php/faceconf.php';
$facebookoklog = "";
$facebookoklog1 = "";
$facebookok = "";
$facebook = new Facebook(array(
'appId' => $appID,
'secret' => $appSecret,
));
$user = $facebook->getUser();
if(empty($user)){
global $facebookok;
$facebookok = "getill";
}
elseif($user){
try{
//get the facebook user profile data
$user_profile = $facebook->api('/me');
$_SESSION['User']=$user_profile;
}catch(FacebookApiException $e){
global $facebookoklog;
global $facebookoklog1;
$facebookoklog = "loggain";
$facebookoklog1 =$e;
}
}
if($facebookoklog=="loggain" || $facebookok=="getill"){ //do this}
else{//dothis}
The normal access token expires in 2 hours, and the extended token lasts for 2 months.
Go though this to get the extended token. Works with perfection:
How to extend access token validity since offline_access deprecation
(You can use Facebook's Debug Tool to check the validity of your access token.)