You are here

function fb_token_invalid in Drupal for Facebook 7.4

When a token is known to have expired, this function flags it no longer valid. It will no longer be a choice in admin forms.

Care must be taken before calling this. A facebook graph request could fail for other reasons (i.e. a timeout or https://developers.facebook.com/bugs/285682524881107/). Should be called only when certain that a token is not valid.

2 calls to fb_token_invalid()
fb_ajax_event in ./fb.module
Menu callback for ajax event.
fb_http in ./fb.module
Wrapper around drupal_http_request() which detects error codes.
1 string reference to 'fb_token_invalid'
fb.module in ./fb.module

File

./fb.module, line 807

Code

function fb_token_invalid($token) {
  db_query("UPDATE {fb_token} SET status = status &~ :valid_flag WHERE access_token=:token", array(
    ':valid_flag' => FB_STATUS_FLAG_VALID,
    ':token' => $token,
  ));
  if (!empty($_SESSION['fb']) && !empty($_SESSION['fb'][$token])) {
    unset($_SESSION['fb'][$token]);
  }
  if (!empty($_SESSION['fb'])) {
    foreach ($_SESSION['fb'] as $fba => $app) {
      if (!empty($app['access_token']) && $app['access_token'] == $token) {
        unset($_SESSION['fb'][$fba]);
      }
    }
  }
  if (empty($_SESSION['fb'])) {
    unset($_SESSION['fb']);
  }

  // Let fb.js know this token is bad.
  drupal_add_js(array(
    'fb' => array(
      'token_invalid' => $token,
    ),
  ), 'setting');

  // Let other modules know this token is bad.
  fb_invoke(FB_OP_TOKEN_INVALID, array(
    'invalid_token' => $token,
  ));
}