function fb_stream_js in Drupal for Facebook 6.2
Same name and namespace in other branches
- 6.3 fb_stream.module \fb_stream_js()
- 7.3 fb_stream.module \fb_stream_js()
Convert our data structure in javascript.
1 call to fb_stream_js()
- fb_stream_fb in ./
fb_stream.module - Implementation of hook_fb().
File
- ./
fb_stream.module, line 96 - 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(
'user_message' => '',
'attachment' => '{}',
'action_links' => '{}',
'target_id' => 'null',
'user_message_prompt' => 'null',
'callback' => '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(
'callback',
'auto_publish',
))) {
// no encoding
$args[] = $params[$key];
}
else {
$args[] = json_encode($params[$key]);
}
}
else {
// Use default
$args[] = $default;
}
}
if (!fb_is_fbml_canvas()) {
// Add stream dialog javascript to a facebook connect page.
$return[] = "FB.Connect.streamPublish(" . implode(', ', $args) . ");\n";
}
else {
// Add stream dialog javascript to a canvas page.
$return[] = "Facebook.streamPublish(" . implode(', ', $args) . ");\n";
}
// debug
//dpm($return, "fb_stream_fb added javascript");
}
return $return;
}