'fb/devel', 'callback' => 'fb_devel_page', 'type' => MENU_CALLBACK, 'access' => TRUE, // TODO: restrict access ); $items[] = array('path' => 'fb/devel/fbu', 'callback' => 'fb_devel_fbu_page', 'type' => MENU_CALLBACK, 'access' => TRUE, ); } return $items; } function fb_devel_fb($op, $data, &$return) { $fb_app = $data['fb_app']; $fb = $data['fb']; if ($op == FB_OP_INITIALIZE) { // Sanity checks for canvas pages. $nid = fb_settings(FB_SETTINGS_APP_NID); if ($nid) { // We're in a canvas page callback, either FBML or iframe if ($nid != $fb_app->nid) { $message = t('fb_app id (%fb_app_id) does not equal fb settings id (%fb_settings_id). This is usually caused by the wrong callback url on your facebook application settings form.', array('%fb_app_id' => $fb_app->nid, '%fb_settings_id' => $nid, '!url' => "http://www.facebook.com/developers/apps.php", )); drupal_set_message($message, 'error'); watchdog('fb_devel', $message); } // Theme sanity check global $theme; // for debug message if (isset($theme)) { $message = t('Drupal for Facebook is unable to override the theme settings. This is usually because some module causes theme_init() to be invoked before fb_init(). See the !readme.', array('!drupal_for_facebook' => l(t('Drupal for Facebook'), 'http://drupal.org/project/fb'), // This link should work with clean URLs // disabled. '!readme' => 'README.txt')); drupal_set_message($message, 'error'); watchdog('fb_devel', $message); } // path replacement sanity check global $base_path; if ($base_path == "/{$fb_app->canvas}/") { $message = t('Facebook canvas page matches Drupal base_path (%base_path). This is currently not supported.', array('%base_path' => $base_path)); drupal_set_message($message, 'error'); watchdog('fb_devel', $message); } } } else if ($op == FB_APP_OP_EVENT) { $type = $data['event_type']; // Facebook has notified us of some event. $message = t('Facebook has notified the %label application of a %type event.', array('%label' => $fb_app->label, '%type' => $type)); $message .= dprint_r($data, 1); $message .= dprint_r($_REQUEST,1); watchdog('fb_devel', $message); } } /** * Provides a page with useful debug info. * */ function fb_devel_page() { global $fb, $fb_app; global $user; if ($_REQUEST['require_login']) $fb->require_login(); if ($fb) { // These will work in a canvas page. drupal_set_message("in_fb_canvas returns " . $fb->in_fb_canvas()); drupal_set_message("get_loggedin_user returns " . $fb->get_loggedin_user()); drupal_set_message("current_url returns " . $fb->current_url()); drupal_set_message("base_url: " . $GLOBALS['base_url']); drupal_set_message("base_path: " . $GLOBALS['base_path']); drupal_set_message("url() returns: " . url()); drupal_set_message("session_key is " . $fb->api_client->session_key); } if ($fbu = fb_get_fbu($user)) { $path = "fb/devel/fbu/$fbu"; drupal_set_message(t("Learn more about the current user at !link", array('!link' => l($path, $path)))); } dpm(fb_get_fbu($user), 'Facebook user via fb_get_fbu'); //dpm($user, "Local user " . theme('username', $user)); if ($GLOBALS['fb_connect_apikey']) drupal_set_message("fb_connect_apikey = " . $GLOBALS['fb_connect_apikey']); dpm($_COOKIE, 'cookie'); dpm($_REQUEST, "Request"); //dpm($fb_app, "fb_app"); drupal_set_message("session_id returns " . session_id()); //dpm($_SESSION, "session:"); return "This is the facebook debug page."; } /** * A page which tests function which work with facebook user ids */ function fb_devel_fbu_page($fbu = NULL) { if ($fbu) { $output = "
Debug info about facebook id $fbu:
\n"; $friends = fb_get_friends($fbu); //dpm($friends, "fb_get_friends($fbu) returned"); $items = array(); foreach ($friends as $_fbu) { $items[] = l($_fbu, "fb/devel/fbu/{$_fbu}"); } if (count($items)) { $output .= "\nKnown friends:
Local friends:
', '#suffix' => '', '#type' => 'markup', '#value' => dprint_r($val, 1)), ); } } // It's not really a form, but we like collapsible fieldsets return $form; } ?>