// to provide it, depending on whether the user has logged in, and whether
// the session has expired.
$fbu = $data['fbu'];
- $result = db_query("SELECT * FROM {fb_user_app} WHERE apikey = '%s' and fbu = %d AND session_key_expires > %d", $fb_app->apikey, $fbu, time());
+ $result = db_query("SELECT * FROM {fb_user_app} WHERE apikey = '%s' and fbu = %d", $fb_app->apikey, $fbu);
$data = db_fetch_object($result);
if ($data && $data->session_key)
// Return array with FB id and apikey.
- $return = array($data->fbu, $data->session_key);
+ $return = array(
+ 'fbu' => $data->fbu,
+ 'access_token' => $data->session_key,
+ 'expires' => $data->session_key_expires,
+ );
}
elseif ($op == FB_OP_AJAX_EVENT) { // handle internal login
// @TODO - global user is not correct here.
// test if we are tracking only those apps that have been granted offline
// access.
$fb_session = $fb->getSession();
+
// when 'expires' == 0 app has been granted offline access
if ($fb_user_type == 'user' &&
$fb_session["expires"] <> 0 &&
<?php
-// $Id: fb.module,v 1.137.2.6 2011/02/23 22:04:37 yogadex Exp $
/**
* @file
$cache[$cache_key] = $session['access_token'];
}
else {
- // @TODO look up another user's access token.
+ $session_data = fb_invoke(FB_OP_GET_USER_SESSION, array(
+ 'fb' => $fb,
+ 'fb_app' => fb_get_app(array('apikey' => $apikey)),
+ 'fbu' => $fbu,
+ ), array());
+ if (count($session_data)) {
+ $cache[$cache_key] = $session_data['access_token'];
+ }
}
}
return isset($cache[$cache_key]) ? $cache[$cache_key] : NULL;