Publishing Drupal Comments To Facebook

Hi folks,

Firsly massive thanks to Dave Cohen for developing this. I'd have been lost without it recently. Every client I see wants FB integration at the moment.

I've got a large site set up where users can join via FB, post photos, video, comments etc. It's for a music artist and they want fans to link into Facebook. We'd like to be able to pull content from Facebook like photos eventually but I'm not sure how we go about that. At the moment I hard coded "like" buttons into the node template and it seems to work. We'd like to have an option to post comments from the Drupal site directly to FB though, and also pull them back out in the comment threads. I've seen modules that allow you to have FB comments but they then remove all the internal Drupal commenting.

I'm new to FB development and still finding my feet with Drupal to be honest, but I did write my first (and successful) 3rd party auth module recently. I also know a fair bit of PHP.

My question is this, are there any modules that integrate FB commenting with Drupal rather than replace standard comments? Also, how do I go about developing this? I presume I need to make a module of my own, or perhaps use functions in the theme. I need to work out how to use the API to send the comment contents to FB and we should probably have a checkbox in the comment form.

Does anyone have any ideas, or maybe even done this before? Many thanks. Sorry for the slightly vague questions.

Dan

Using Open grapn and new object:actions

Hi, I want to share how I put comment in timeline

<?php
function fb_extras_comment_insert($comment) {
    global
$user;
   
   
$node = node_load($comment->nid);
   
   
$action = 'comment';
   
$object = 'anuncio'; //TODO: get from content type
   
$params = array(
       
$object => url('node/'.$comment->nid, array('absolute' => TRUE, 'fb_canvas' => FALSE))   
    );
   
   
$gid = fb_graph_publish_action($action, $params);
   
    if (
$gid) {
       
watchdog('fb', 'Comment added to timeline');
    }
   
   
// Post comment in node author feed
   
if ($node->uid != $comment->uid) {
       
//TODO: notify node author about this new comment
   
}
   
}
?>

Some notes

- You need define object (in my case "anuncio", and action "comment" in your app settings (in developers.facebo...)
- You need setup open graph in your content type (I didn't use this info in the code yet)
- Facebook "scrape" the url of the node for get the object, then build the correct timeline text "Mark comment an anuncio in Listing", etc

testing

testing this comment.. will it be shown on facebook?

Comments posted to timeline

When you post a comment here, it's stored in Drupal's database, and the content of the comment is not stored on facebook as well. With a little custom code you could do that.

But consider instead doing what this site now does. When a comment is posted here, a link is posted to my facebook timeline. So my friends might see that activity and click a link that brings them here to this site. (This site has had the feature for a while, but facebook only recently approved this "action" so before a couple days ago only developers would have seen the activity.) If you want to test this, go to "my account", then "edit" and check the "publish to timeline" checkbox and finally hit Save button to store that setting. Then when you posts a comment (hint: use the test forum for testing!) you should see it on your timeline.

A similar thing will happen when posting a node, but that action is not yet approved so for now only developers can see it. But you might find this patch does what you want one better when posting nodes: https://bbs.archlinux.org/search.php?search_id=1743522806

Comment

will this comment post to Facebook? :) But it looks like a drupal only posting.

Post To Facebook

Check out the Post to Facebook module. It supports some two-way syncing. Posting content to facebook, and also posting comments from facebook back to Drupal.

Facebook Wall to Drupal Sync

I've been asked about true two-way integration, where comments posted to facebook are full-fledged comments in Drupal, and vice versa. I think facebook's APIs make such a thing possible, but not trivial.

If you're interested in working on a module to support this, ping me about it. I'd like to put together a team capable of building this.

Very interesting

I would like to see the sync function very much. Although i m quite a newbie, please let me know anything i could be useful

I got this sorted in the end

I got this sorted in the end by copying the sample code on Drupal.org for adding a checkbox to publish comments and nodes to Facebook. The very code used on this forum apparently. I copied into my own module and it seems to work great.

Please can you share your

Please can you share your module here?
Thanks
Srini

The code used here is now

The code used here is now included in Drupal for Facebook. See modules/fb/contrib/fb_example.module.