You are here

function fb_devel_page in Drupal for Facebook 7.4

Same name and namespace in other branches
  1. 5.2 fb_devel.module \fb_devel_page()
  2. 5 fb_devel.module \fb_devel_page()
  3. 6.3 fb_devel.module \fb_devel_page()
  4. 6.2 fb_devel.module \fb_devel_page()
  5. 7.3 fb_devel.module \fb_devel_page()

Provides a page with useful debug info.

1 string reference to 'fb_devel_page'
fb_devel_menu in ./fb_devel.module

File

./fb_devel.module, line 103
Makes development with Drupal for Facebook much easier. Keep this module enabled until you're confident your app works perfectly.

Code

function fb_devel_page($id = NULL) {
  try {
    $markup = array(
      '#type' => 'markup',
      '#prefix' => '<p>',
      '#suffix' => '</p>',
    );
    $app = fb_get_app();
    if (!empty($_REQUEST['signed_request'])) {
      $sr = fb_parse_signed_request($_REQUEST['signed_request'], !empty($app['secret']) ? $app['secret'] : NULL);
      $output[] = $markup + array(
        '#markup' => 'signed request is ' . dprint_r($sr, 1),
      );
    }
    $graph_params = array();
    if (!empty($app['data']) && !empty($app['data']['access_token'])) {
      $graph_params['access_token'] = $app['data']['access_token'];
    }
    if ($id) {
      try {
        $graph = fb_graph($id, $graph_params);
        $output[$id] = $markup + array(
          '#markup' => 'fb_graph(' . $id . '):' . dprint_r($graph, TRUE),
        );
      } catch (Exception $e) {
        $output[$id] = $markup + array(
          '#markup' => 'fb_graph(' . $id . ') failed:' . dprint_r($e, TRUE),
        );
      }
    }
    if (!empty($app['secret'])) {
      $app['secret'] = t('<hidden>');
    }
    if (!empty($app['data']) && !empty($app['data']['access_token'])) {
      $app['sdata'] = t('<hidden>');
      $app['data']['access_token'] = t('<hidden>');
    }
    $output[] = $markup + array(
      '#markup' => 'fb_app() = ' . dprint_r($app, 1),
    );
    $user_token = fb_user_token();
    $output['fb_user_token'] = $markup + array(
      '#markup' => 'fb_user_token() = ' . fb_user_token(),
    );
    $output['fb_server_auth_url'] = array(
      '#markup' => 'Server-side auth test ' . l('fb_server_auth_url()', fb_server_auth_url()),
    ) + $markup;
    $output['fb_client_auth_url'] = array(
      '#markup' => 'Client-side auth test ' . l('fb_client_auth_url()', fb_client_auth_url()),
    ) + $markup;
    if ($user_token) {
      $output['graph'] = $markup + array(
        '#markup' => 'fb_graph_batch() with user token:' . dprint_r(fb_graph_batch(array(
          'me',
          'app',
        ), fb_user_token()), TRUE),
      );
    }
  } catch (exception $e) {
    $output[] = $markup + array(
      '#markup' => 'Exception: ' . $e,
    );
    drupal_set_message($e
      ->getMessage(), 'error');
  }
  $output[] = $markup + array(
    '#markup' => '$_REQUEST = ' . dprint_r($_REQUEST, 1),
  );

  // Show session data, but not messages.
  $session = $_SESSION;
  unset($session['messages']);
  $output[] = $markup + array(
    '#markup' => '$_SESSION = ' . dprint_r($session, 1),
  );
  return $output;
}