function fb_example_comment_update in Drupal for Facebook 7.3
Implements hook_comment_update().
Publish to facebook Walls when users submit comments.
File
- contrib/
fb_example.module, line 217 - Example customizations to modules/fb.
Code
function fb_example_comment_update($comment) {
if ($comment->stream_publish) {
//dpm($a1, "fb_example_comment, publishing to stream");
$node = node_load($comment->nid);
// http://wiki.developers.facebook.com/index.php/Attachment_(Streams)
$attachment = array(
'name' => $comment->subject,
'href' => url('node/' . $comment->nid, array(
'absolute' => TRUE,
'fragment' => 'comment-' . $comment->cid,
)),
'description' => $comment->comment_body[$comment->language][0]['value'],
);
if ($logo_path = theme_get_setting('logo_path')) {
$url = url($logo_path, array(
'absolute' => TRUE,
));
//dpm($logo_path, "logo_path is $logo_path and url is $url");
$attachment['media'][] = array(
'type' => 'image',
'src' => $url,
'href' => $url,
);
}
$user_message = t('Check out my latest comment on !site...', array(
'!site' => variable_get('site_name', t('my Drupal for Facebook powered site')),
));
$actions = array();
$actions[] = array(
'text' => t('Read More'),
'href' => url('node/' . $comment->nid, array(
'absolute' => TRUE,
)),
);
fb_stream_publish_dialog(array(
'message' => $user_message,
'attachment' => $attachment,
'action_links' => $actions,
));
}
}