public function JanrainCaptureApi::loadUserEntity in Janrain Registration 6
Same name and namespace in other branches
- 7.4 includes/janrain_capture.api.inc \JanrainCaptureApi::loadUserEntity()
- 7 janrain_capture.api.inc \JanrainCaptureApi::loadUserEntity()
- 7.2 includes/janrain_capture.api.inc \JanrainCaptureApi::loadUserEntity()
- 7.3 includes/janrain_capture.api.inc \JanrainCaptureApi::loadUserEntity()
Retrives the user entity from Capture
Parameters
boolean $can_refresh: Allow this function to refresh the token set if needed
Return value
mixed The entity retrieved or null
File
- ./
janrain_capture.api.inc, line 226 - API Client for making calls to the Janrain Capture web service
Class
- JanrainCaptureApi
- @file API Client for making calls to the Janrain Capture web service
Code
public function loadUserEntity($can_refresh = TRUE) {
if (empty($_SESSION['janrain_capture_access_token'])) {
return NULL;
}
$user_entity = NULL;
$need_to_refresh = FALSE;
// Check if we need to refresh the access token.
if (REQUEST_TIME >= $_SESSION['janrain_capture_expires_in']) {
$need_to_refresh = TRUE;
}
else {
$user_entity = $this
->call('entity', array(), $_SESSION['janrain_capture_access_token']);
if (isset($user_entity['code']) && $user_entity['code'] == '414') {
$need_to_refresh = TRUE;
}
}
// If necessary, refresh the access token and try to fetch the entity again.
if ($need_to_refresh && $can_refresh) {
if ($this
->refreshAccessToken()) {
$user_entity = $this
->loadUserEntity(FALSE);
}
}
// Return NULL if there is an error code.
return isset($user_entity['code']) ? NULL : $user_entity;
}