You are here

function fb_infinite_display_page in Drupal for Facebook 5.2

Same name and namespace in other branches
  1. 5 fb_infinite.module \fb_infinite_display_page()

Menu callback. Ensures the user is logged in and displays user id and session key.

1 string reference to 'fb_infinite_display_page'
fb_infinite_menu in ./fb_infinite.module
hook_menu

File

./fb_infinite.module, line 145
This module manages an infinite session for each Facebook App. http://wiki.developers.facebook.com/index.php/Infinite_session_keys

Code

function fb_infinite_display_page() {
  global $fb, $fb_app;
  if (!$fb_app) {
    drupal_set_message(t('This page must be viewed as a Facebook canvas page.'), 'error');
    drupal_not_found();
    exit;
  }
  $fbu = $fb
    ->require_login();
  if ($fb->api_client
    ->users_hasAppPermission('offline_access')) {
    $output .= '<p>' . t('Facebook user id: %fbu', array(
      '%fbu' => $fb->api_client
        ->users_getLoggedInUser(),
    )) . '</p>';
    $output .= '<p>' . t('Facebook session key: %session', array(
      '%session' => $fb->api_client->session_key,
    )) . '</p>';
    $output .= '<p>' . t('Use the values above when configuring the infinite session of your Facebook App.') . '</p>';
  }
  else {
    $output .= '<p><fb:prompt-permission perms="offline_access">' . t('Click here for a session that will not expire.') . '</fb:prompt-permission></p>';
    $output .= '<p>' . t('Refresh your browser after clicking the above link.') . '</p>';
  }
  return $output;
}