You are here

function fb_feed_show_dialog in Drupal for Facebook 5.2

Publish a feed message via the Feed Dialog. This will prompt the user before writing to the feed, and this is Facebook's recommended technique. The other option is publishUserAction.

Our approach here is like drupal_set_message. We save the data to the session, and show the user the dialog on the next page request.

1 call to fb_feed_show_dialog()
fb_feed_action_show_dialog in ./fb_feed.module
1 string reference to 'fb_feed_show_dialog'
fb_feed_action_show_dialog in ./fb_feed.module

File

./fb_feed.module, line 522
Helpers for Facebook feeds (http://wiki.developers.facebook.com/index.php/New_Design_Feed_Wall)

Code

function fb_feed_show_dialog($fb_feed_nid, $tokens, $options) {
  if (!isset($_SESSION['fb_feed_dialogs'])) {
    $_SESSION['fb_feed_dialogs'] = array();
  }

  // Accept either nid or template as first param.
  if (is_object($fb_feed_nid)) {
    $template = $fb_feed_nid;
  }
  else {
    $template = node_load($fb_feed_nid);
  }
  if ($template) {

    // Change token data structure.
    if (is_object($tokens) && is_array($tokens->tokens)) {
      foreach ($tokens->tokens as $i => $key) {
        $fb_tokens[$key] = $tokens->values[$i];
      }
    }
    else {
      $fb_tokens = $tokens;
    }
    if (!isset($_SESSION['fb_feed_dialogs'][$template->apikey])) {
      $_SESSION['fb_feed_dialogs'][$template->apikey] = array();
    }
    $_SESSION['fb_feed_dialogs'][$template->apikey][] = array(
      'fb_feed_nid' => $template->nid,
      'apikey' => $template->apikey,
      'bundle_id' => $template->bundle_id,
      'tokens' => $fb_tokens,
      'options' => $options,
    );
  }
  else {

    // TODO: log error.
  }
}