You are here

function fb_feed_insert in Drupal for Facebook 5.2

File

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

Code

function fb_feed_insert($node) {

  // Register the new template with facebook.
  $bundle_id = fb_feed_register_template($node);
  if (!$bundle_id) {

    // Show an error, but save the node anyway.
    drupal_set_message(t('Failed to register template bundle with Facebook.  This template bundle may not be used.'), 'error');
  }
  $data = serialize($node->fb_feed_data);

  // We're going to save the apikey, although it may be redundant with the
  // fb_app_nid, so that we can detect any inconsistencies (i.e. the apikey
  // has changed on us).
  $fb_app = fb_get_app(array(
    'nid' => $node->fb_app_nid,
  ));
  db_query("INSERT INTO {fb_feed_template} (nid, fb_app_nid, apikey, bundle_id, fb_feed_data) VALUES (%d, %d, '%s', %f, '%s')", $node->nid, $node->fb_app_nid, $fb_app->apikey, $bundle_id, $data);
  if ($bundle_id) {
    watchdog('fb_feed', t('Registered Facebook feed template bundle %id for application %app', array(
      '%id' => $bundle_id,
      '%app' => $fb_app->title,
    )));
  }
}