You are here

function fb_stream_js in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 6.3 fb_stream.module \fb_stream_js()
  2. 6.2 fb_stream.module \fb_stream_js()

Convert our data structure to javascript.

1 call to fb_stream_js()
fb_stream_fb in ./fb_stream.module
Implementation of hook_fb().

File

./fb_stream.module, line 493
Support for Facebook's Stream API.

Code

function fb_stream_js($params_array) {
  $return = array();
  foreach ($params_array as $params) {

    /*
    $args = array();
    // These are the defaults:
    foreach (array(
               'method' => '"stream.publish"',
               'user_message' => '',
               'attachment' => '{}',
               'action_links' => '{}',
               'target_id' => 'null',
               'user_message_prompt' => 'null',
               'auto_publish' => 'null',
               'actor_id' => 'null',
             ) as $key => $default) {
      if (isset($params[$key])) {
        // Encode the params passed to fb_stream_publish_dialog.
        if (in_array($key, array('auto_publish'))) {
          // no encoding
          $args[$key] = $params[$key];
        }
        else {
          $args[] = json_encode($params[$key]);
        }

      }
      else {
        // Use default
        $args[] = $default;
      }
    }
    */
    $params['method'] = 'stream.publish';

    // Add stream dialog javascript to a canvas page.
    $return[] = "FB.ui(" . json_encode($params) . ");\n";
  }
  return $return;
}