You are here

function fb_app_event_cb in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 5.2 fb_app.module \fb_app_event_cb()
  2. 6.3 fb_app.module \fb_app_event_cb()
  3. 6.2 fb_app.module \fb_app_event_cb()

Callback for FB_APP_PATH_EVENT.

We don't act on the events directly. We pass the information along via hook_fb. Other modules are thus notified of the event and can take action.

1 string reference to 'fb_app_event_cb'
fb_app_menu in ./fb_app.module
Implements hook_menu().

File

./fb_app.module, line 147
Implementation of Drupal for Facebook application.

Code

function fb_app_event_cb($label, $event_type) {
  $fb_app = fb_get_app(array(
    'label' => $label,
  ));
  if ($fb_app) {
    $fb = fb_api_init($fb_app);
  }
  $data = array(
    'fb_app' => $fb_app,
    'fb' => $fb,
    'event_type' => $event_type,
  );
  if (isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] == 'application/json') {
    $json = file_get_contents('php://input');
    $data['event_data'] = json_decode($json);
  }
  else {
    $data['event_data'] = $_REQUEST;
  }
  fb_invoke(FB_APP_OP_EVENT, $data, NULL);

  // This page is called by facebook, not a user's browser.  User's should never see this.

  //print('Thanks Facebook, for your fancy API!');

  // It's facebook calling us, not the user.  And fb_sig params make it look
  // like a canvas page, but it could be connect.  So bad idea to save session.
  drupal_save_session(FALSE);
  exit;
}