You are here

function fb_tab_added in Drupal for Facebook 6.3

Same name and namespace in other branches
  1. 7.3 fb_tab.module \fb_tab_added()

Drupal menu callback. User has added a tab to one of their pages.

1 string reference to 'fb_tab_added'
fb_tab_menu in ./fb_tab.module

File

./fb_tab.module, line 410
This module provides support for "Profile Tabs" that can be added to facebook pages (no longer allowed for user profiles).

Code

function fb_tab_added($fb_app) {

  //dpm($_REQUEST, __FUNCTION__); // debug what facebook has passed to us
  foreach ($_REQUEST['tabs_added'] as $page_id => $added) {

    // TODO use batch graph api.
    $graph = fb_graph($page_id, array());
    watchdog('fb_tab', "Facebook application %label (%app_id) added to page %name (%page_id)", array(
      '%label' => $fb_app->label,
      '%app_id' => $fb_app->id,
      '%name' => $graph['name'],
      '%page_id' => $graph['id'],
    ));
  }

  // Redirect user to the page tab they've added.
  if ($graph['link']) {

    // This undocumented format seems to be the right URL for a page tab.
    $url = $graph['link'] . '?sk=app_' . $fb_app->id;
    drupal_goto($url);
  }

  // If drupal_goto succeeds, user will not see this.
  return t('Added application to Facebook page.');
}