I read the README.txt from start to finish.

Hello, I'm trying to make it so when users post blogs, or other types of nodes, they have the option to post it to their wall on facebook to let their friends view.
I've read the documentation at:
http://drupal.org/node/685320

But I'm still kind of a Drupal and PHP novice. I can kind of understand the code posted if I read it, but I'm not sure where to put the code?

As of right now out of the box, the module doesn't add the option to publish to facebook walls on nodes, I understand this all has to be manually coded in? If anyone knows a little more specific and easier to follow instructions, it would be very helpful!

Comments

Dave Cohen’s picture

Search drupal.org and the web in general for good instructions on how to build a module. You really should have some knowledge of Drupal before diving into this stuff. There's good documentation out there, I don't have a link handy but it should be easy to find.

pribeh’s picture

Is there nothing like this that comes with Drupal for Facebook?

Hey SewFresh, you might want to check out fbconnect's code since I believe they just added the ability to post nodes to a user's wall in their dev. I would very much so be interested in this however am not a programmer.

summit’s picture

Subscribing, can I publish nodes on FB userpage with this module? like I can with the twitter module?
greetings, Martijn

WildBill’s picture

Why is the code at http://drupal.org/node/685320 not included as a part of the standard fb_stream.module? Why is it separated out like that? Must be a good reason.

Dave Cohen’s picture

That code is separated out because it's not a one-size-fits-all solution. Note for example, that Miquel Carol added to the comments a version that uses the Image Field module.

Some site admins might want this function for some content types but not others. Some might want other custom links different from "read more". Some might want different user_message text. There are so many variables here that it's difficult to write a module to configure them all, but pretty easy to edit some PHP.

So the idea is in fb_stream.module to support the most basic helper functions, but not try to be all things to all people. How to make this easier for non-programmers? I'm not sure. Maybe there should be a module in modules/fb/contrib/. Maybe someone can submit another drupal module that adds some commonly requested features like this. I'm not sure, I just don't want to check in a bunch of code that I may not be able to support long-term.

summit’s picture

Hi,
+1 for modules/fb/contrib solution!

I think to post it as contributed module in modules/fb/contrib/ would be great! Then it is still maintained within fb scope (doesn't mean you have to work more on it), and patches can be send in by the community.

greetings, Martijn

nancydru’s picture

rgs’s picture

Version: 6.x-2.0-rc1 » 6.x-3.x-dev
Priority: Normal » Critical

Hi folks. I have read the read me from start to finish, as well as all the other posts on this subject. Thanks so much for all the hard work from Dave and the community. I have built the basic module for publishing to walls and it is not working. I'm not sure if I have done something wrong or if it is simply not meant for the 3.0 branch? I've logged in through fb connect, etc., enabled the module, but still no sign of the option in node create or comment. Is it me or is it that this is not yet supported in 3.0 branch? Help please. Thanks.

srinikasturi’s picture

This seems to me a common enough request but the fact that no one has posted a zipped module up makes me think there's an elephant in the room :)

i would gladly post mine if it worked.

I followed the instructions on creating a module, copied Dave Cohen's code, FTPed, enabled, and...nothing. I didn't see the tickbox to post to stream on any content type. The other thing I failed at with similar results is the like button.

Grateful if anyone can post zips of these 2 modules for general use.

Thanks.

srinikasturi’s picture

StatusFileSize
new2.25 KB

I've attached a zip with 2 modules that have the code for adding the like button and the publish to stream checkbox, and *do not work*. Any help please on what is missing here?

Thanks
Srini

srinikasturi’s picture

OK, the like module in the attachment in #10 works, but the publish to fb stream doesn't.

rgs’s picture

Same experience. My own stream module did not work either.has anyone gotten it working in 3.0 branch?

This is an enormously important feature. Would be much appreciated to have a little more feedback from others as to whether this works for them. Maybe a few other folks could try these modules? Thank you srinikasturi for posting.

rgs’s picture

Just tried Miquel Carol's module 'field_imagefb' from http://drupal.org/node/685320 and it did not work.
Can't help feeling like we are barking up a dead tree here -- that this worked in the 2.0 branch but something different needs to be done for 3.0? Grasping at straws...

rgs’s picture

I just took the Drupal for Facebook tour again and i see that when i go to create a forum topic there is indeed a check box tor 'share on facebook' so clearly this feature does work on the 3.0 branch and i have done something wrong somewhere. Everything else seems to work like a charm. Little help please, any help, please? Have provided install details above - won't clutter the thread by restating. Any help will be much appreciated.

nancydru’s picture

I got the checkbox to show up; I've never been concerned about that. The problem is that the post is not going to FB.

rgs’s picture

O boy. Something to look forward to. Would you mind posting your info and module files for srinikasturi and I? If it does not work with your module then it may be theme related. I'm guessing. If we do get it working you will have two more folks trying to actually get it to post:-)

nancydru’s picture

StatusFileSize
new3.1 KB

Here it is, although I honestly don't see it being of much help.

fehin’s picture

I found this module http://drupal.org/project/facebookshare, has anyone tried it?

fehin’s picture

I have been researching the best solution for this but i'm a little confused, don't those ShareThis, AddtoAny type of modules publish the node to facebook? Would one of those kind of modules be enough to get users to publish nodes to their facebook walls?

Dave Cohen’s picture

You can use those share modules to post a URL to a user's wall.

The technique described at http://drupal.org/node/685320 allows you to post to user's wall or other facebook pages. You have more control over the post - for example, which media or action links appear. And more control over when the post dialog appears - for example, in response to a node post, rather than hitting a button on the node page.

fehin’s picture

Thanks Dave for the info. The ability to post a node into facebook during node creation sounds like a good idea. I found this module http://drupal.org/project/postiteverywhere but I'm not sure if it's conflicts with DFF.

masipila’s picture

Hi,

I had problems to get the checkboxes to show up in the technique described at http://drupal.org/node/685320. I modified the hook_alter_form -function a little bit because the $GLOBALS['fb'] was not set and thus the checkboxes were not added. The modification can be found from this comment: http://drupal.org/node/685320#comment-3160164

nancydru’s picture

@masipila: it can also be found in comment #17 above.

Dave Cohen’s picture

I changed the two globals, originally $fb and $fb_app, to be $_fb and $_fb_app because the coder module told me to. Sorry for the confusion, just use $GLOBALS['_fb'] instead.

summit’s picture

Hi
Could anyone post here a working method please? like the twitter 2.6 module?
Thanks a lot in advance!
greetings, Martijn

rgs’s picture

StatusFileSize
new1.11 KB

Working like a charm now. Thank you masipila and everyone else.
See attached module file 'fb_node_pub'

summit’s picture

Hi, will this module gets its own drupal.org page?
Would be great so people also can file issues, if any, right?
greetings,
Martijn

rgs’s picture

Will work on it.

rgs’s picture

As much as folks seem to need this module - i sure could have used it - i am concerned about just adding to the list of facebook modules - especially in the context of Dave's comment (post 5). How would one go about including it in 'modules/fb/contrib/' Or should the documentation just be updated to include the correct module code and a little more detailed instructions?

masipila’s picture

I totally agree with Dave that it would be very hard to write a one-size-fits-all module. I guess that an example module with good documentation (and pointers to general module development tutorials) would be the best solution for at least now when the whole dff module is still under development.

There are so many different use cases that could be imagined - the Graph API gives us so much flexibility that people like me are just realizing when they get their hands dirty with their first fb connect site. An example module that shows how you implement different API stuff would be great - but it would be just an example for your own custom module that does just what it is needed in your case.

nancydru’s picture

I can do development, but I couldn't even get my version to post. Perhaps I can now drop back and start with this code. So, yes, a working example is a good start.

rgs’s picture

I will gladly begin working on detailed instructions to go along with the basic sample code to update the documentation. Have other folks had success with the code posted in comment 26?

masipila’s picture

I'll be glad to contribute some examples to this example module as well.

I'm currently developing some graph API stuff (which turned out to be very simple) but it took me a good while to figure out how one is supposed to call the APIs. The FB Graph API page talks about curl stuff (see section "Publishing to Facebook") but the actual HTTP requests made with curl are abstracted like two or three layers below...

By the way - should we start a new issue for this example module? The current name of this issue refers to publishing to Facebook but I could easily imagine that the example module could end up having examples of other things as well (how to read from Graph API, how to write to Graph API, etc).

Markus

srinikasturi’s picture

rgs, the code works beautifully. Thank you!

rgs’s picture

Glad it's working. I think eventually the best place for the various module code and instructions would be in the 'FB Recipes' - http://drupal.org/node/205481
In the meantime we could start an 'example modules' issue?

artwork’s picture

I have problem with user_message. Its always blank, does user_message work for you guys ?

Thanks,

rgs’s picture

No. Not blank for me. Working fine. Does it post to your wall and your friends' news feed?

summit’s picture

Hi, I added module #26 to modules/fb/contrib but couldn't see the module with admin/build/modules under drupal for facebook. Is this normal behaviour?
Would love to be able to add nodes to facebook, like with twitter. Optiimal scenario is to be able to post the node teasers to facebook.
greetings, Martijn

nancydru’s picture

Priority: Critical » Normal

Martijn, that zip file does not include an info file, which is needed to make it work.

rgs’s picture

Exactly. I didn't even think to include it with the zip. Let me know if you need it and i will be happy to upload another zip to avoid same problem for others. Some folks may have different preferences as to what field group it goes into. I just put it in 'other'.

summit’s picture

Hi, yes please for new zip. And wouldn't it be right to put it into the FB group?
Do we need drupal for Facebook installed to have it working, or is it independent?
Please also put the dependencies into the .info file.

Thanks a lot in advance for the effort!
greetings, Martijn

Jean Rodas’s picture

For me just when a user login to the site, asks for permission to add content but when he/she comment or post new content nothing happen and facebook wall dont have nothing neither. Please help!

Jean Rodas’s picture

StatusFileSize
new2.38 KB

Finally did it. For newbies like me. Just unziped, placed in your modules folder, and enable it in admin.

escore’s picture

Does this code still work? I had problems with similar code (http://drupal.org/node/870544) and it seems FB has made changes to the argument names ('user_message' -> 'message') for the streamPublish methods (http://wiki.developers.facebook.com/index.php/Stream.publish).

Jean Rodas’s picture

Still work for me!

Edit: Now it's not working.

Just change 'user_message' for 'message'

Thanks escore

Jean Rodas’s picture

I have a new promblem with publish to users wall.

When users sent their comment to Facebook Wall, if the comment is too long its not send it right or Facebook don't recibe it right(Nothing related with the comment is send it or recibe it) because Facebook only accept 420 characters in the Wall.

So if someone could help me with that or point me how can i trim the comment in a simple way because i don't have much experience with php i'll be bery thankfull.

masipila’s picture

Jean, you need to run the PHP variable containing your message text through a truncate function.

Drupal has a function called truncate_utf8(), see http://api.drupal.org/api/function/truncate_utf8/6

Let's assume your message is in variable $message. You truncate it like this

$message = truncate_utf8($message, 415, TRUE, TRUE);
Jean Rodas’s picture

Thanks masapila for taking the time i'll try to do that now!!

kiwad’s picture

For those of you who just want to post content of a site to its facebook wall, you might want to use rules+mimemail to send an email to your secret email address given by Facebook in its mobile tools (for pages or accounts).

Best trick would be to create a CCK limited to 420 caracters and use the content of this CCK as the title of your email.

In my nodes (such as blog) I'm using a conditional CCK field "Post on Facebook" yes|no -> if yes, there is a text zone that I limit to 400 car.

Then, in rules, I set a condition IF "post on facebook" = yes THEN Send a mail to an arbitrary mail address and I set the title of my email as to be my [node:field_facebook_texte-formatted] [site:url]/node/[node:nid] (still need to install a link shorten to use aliases)

Adding an image is still tricky, but there is a patch to mimemail that I haven't tried yet which should allow you to add files to emails

butler360’s picture

Subscribing.

Dave Cohen’s picture

Component: Code » Documentation
Status: Active » Fixed

I checked in an example module into 6.x-3.x-dev. The code used by drupalforfacebook.org to publish to walls is in there. I plan to put other examples of common customizations in there as well.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Marko B’s picture

This is such confusion!
Is Stream module API or normal module?
Where to put #43, what are dependencies?

Can i post to my facebook wall without making an APP? apperently you cannot as you have to make app to use connect, at least this facebook connect.

Readme says " Enable fb_app.module and fb_user.module if you plan to create facebook applications." Can you use facebook for drupal in any way if you don't create app? This would seem you can, but i cannot see any use?

Dave Cohen’s picture

Hey, it's not perfect. But commenting on closed threads only makes it more confusing.

You need an app to publish to a wall. Without an app, you can use social plugins (i.e. Like Button).

the 3.x branch now includes fb_example.module, which has some code examples including a way to publish to user's wall.

Marko B’s picture

Sorry for confusion Dave, you can delete my posts if you want to make it more clear.

marcus178’s picture

Do you have any examples of how your using the Graph API, been tried to figure out how to implement it in a module all day with no success.

wonka68’s picture

Any chance anyone can answer a question related to this issue?

I've applied the new module, and installed Drupal for facebook, and enabled ALL the modules, but the "share in facebook" checkbox won't appear in a node when creating/updating.

After a bit of debugging, I can see the failure occurs in the call to fb_facebook_user - it returns nothing.

I guessed that this might be because I hadn't got an facebook apps registered, although nobody mentioned that above...

So I registered an app in facebook, following instructions in drupal for facebook docs, readme. But now I get SSL error & fb_call_method failure, so I've come to a dead end.

So, could somebody confirm if there is any need to register a FB app, and if not, what could I be doing wrong?

wonka68’s picture

Well, after many many hours of trying, I eventually got this to work. I have to say, the documentation, or lack of documentation, stinks. I salute and applaud whoever took the time and trouble to develop the API, but crucial prerequisites are simply not mentioned. What's worse, there is a list of instructions that lull you into a false sense of security - you would expect that by following them to the letter that this publishing module would work. Not true though.

This is a failing of lots of software developers - not bothering to write up the "unglamorous" documentation. Please please please don't shoot yourself in the foot by neglecting this.

What I had trouble with was the "share in Facebook" checkbox failing to appear. I traced it to the line:
If (fb_facebook_user()) and further down the stack, found there was no Facebook session.

I even installed a Debugger to go through line by line.

The answer was that I didn't have the Facebook Connect block enabled in the Block configuration.

I'd also neglected to create a Facebook application within my Facebook profile, and you also need to register this in the Facebook settings within Drupal. To be fair, these 2 issues had been mentioned by other Users, so I had picked up on this.

WildBill’s picture

Well, after many many hours of trying, I eventually got this to work. I have to say, the documentation, or lack of documentation, stinks.

@wonka68 - This is open source software, provided free to you by a developer who most likely doesn't make any money off of it. If you think the documentation is insufficient, why don't you edit it? Every Drupal user has the ability to edit the documentation, so instead of complaining, contribute something back to the community!

For the record, I found the documentation pretty straightforward and easy to follow.

The answer was that I didn't have the Facebook Connect block enabled in the Block configuration.

I don't have the Facebook Connect block enabled on my site, and I see my "Share on Facebook" checkbox just fine. These two things are unrelated.

I'd also neglected to create a Facebook application within my Facebook profile, and you also need to register this in the Facebook settings within Drupal. To be fair, these 2 issues had been mentioned by other Users, so I had picked up on this.

These are the first things mentioned in the documentation! Did you even read it?

pribeh’s picture

Bump what WildBill said.

Marko B’s picture

The problem is that most users (me inc.) think ok i will install this module and as usuall on some config screen just select on which node types i want comments, add connect block to login, add stream as block etc and its just not happening that way. This module needs much more effort and should probably be more of an API as in most ways it is, isnt it?

WildBill’s picture

@deepM - So essentially, you wish this module was something else?

What does comments have to do with this module? If you want Facebook Comments, just add the <fb:comments> tag in a block.

For the record, if you follow the very clear documentation, you can set up this module in under an hour. If you don't follow the documentation, you will spend hours trying to fix the problems you've created.

Marko B’s picture

My wishes have nothing to to with this :-) I can setup this module in minutes now when i got all the info from docs and maybe even more form different issues.
Just saying maybe this should then be called API so people expect they have to code. As this maybe isnt "the drupal way" whatever that is :-) as majority of modules you setup without coding.

maxchock’s picture

can this custom module work on Drupal 7?

Thanks.

Net Mystic’s picture

Thanks KIWAD!!

After trying just about every other method mentioned in Drupal forums, I used this method for my Facebook site (http://www.facebook.com/nirvananetsolutions). And posting to my app fanpage's wall works great! I followed KIWAD's advice (comment #49) and tweaked it for a few FB process changes since. Here's how I did it:

  1. Created a Post to Wall conditional CCK field in the Blog Entry content type (yes/no radio button)
  2. Created a Wall Post CCK field in Blog Entry content type (text area field limited to 400 chars), conditional on the Post to Wall CCK field
  3. Created a triggered rule; the rule looks like:
    ON event Content is going to be saved
    IF
    AND group
    NOT
    condition-Node not published indent
    AND
    condition-Node is now published indent
    AND
    condition-Controlled field is triggered indent
    DO
    action-Show message that node is now published
    action-Send an HTML mail to an arbitrary mail address

    In rules-send email to arbitrary action settings, make the email address an existing gmail account. The wall post CCK field token is used as the subject of the email. This is b/c the email's subject actually appears as the body of the wall post, by FB default.
  4. In my gmail account settings (pulldown from the gear), i create a filter set to all emails from my Drupal site's email address. These skip the inbox, are moved into a sub-label, and forwarded to my FB page's secret email address. This way they pop up inside a gmail folder for logging purposes, and are then sent to my fanpage wall.

In this manner, site users can choose to post to the fanpage wall when writing blogs. If they choose "yes", they can type a synopsis of the blog as a wall post, and it's automatically posted upon save. If they schedule the node to be published later, the wall post will be published at that time. Voila!

Note: The gmail account is used b/c Facebook will not accept email wall posts unless from a supported mail server type (currently only gmail, yahoo, or msn). My mimemail failed to post by email when I sent to the secret email directly. By forwarding through a gmail account, I was able to make this work. Good luck!

schackattack’s picture

Is there any way to make the module in #43 work on facebook pages as well?

Dave Cohen’s picture

The way I see it there are two commonly requested features for this.

One is that connected users can easily echo their drupal posts onto their facebook wall/timeline.

The other is that an administrator can configure Drupal so that some content is echoed to a particular facebook fan page. I.e. if I add a story to a site it will appear on facebook even if I am not currently connected to facebook.

For those of you interested in the latter (the site-wide setting), see #1454736: Post Content to Facebook Page using fb_stream.module.

Dave Cohen’s picture

Status: Closed (fixed) » Fixed

Changing status so more people will see that last comment.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Marko B’s picture

Yes Dave, you are right, I could have told you this 2 years ago as it is obvious :-)
I make this always by myself as you suggested long time ago, with custom module, but you should consider bringing this into relase or even make a separate module. This feat. and this
http://drupal.org/project/fb_social will satisfy 90% percent or more of users needs so this module will be probably less used but then again issue que will be much smaller.

kevinquillen’s picture

All I want to do is implement a checkbox with FAPI that publishes to a users stream. This used to work, but now it doesn't work anymore. The code has not changed since it launched. Where can I start looking?

Edit: Firebug reports this warning when clicking 'Share with Facebook!' button (invoked with fb canvas):

FB.login() called when user is already connected.

kevinquillen’s picture

Heres how I just fixed my code...:


$access_token = fb_get_token();

if ($GLOBALS['_fb'] && strlen($access_token)) {
            if (in_array($form_id, array('entry_node_form', 'album_node_form'))) {
              // Add checkbox to control feed publish.
              $form['dff_custom']['stream_publish'] = array(
                '#type' => 'checkbox',
                '#title' => 'Share your new '. $form['type']['#value'] . ' on Facebook!',
                '#default_value' => TRUE,                                         
              );
              $form['dff_custom']['#weight'] = 100;
            }
    } else {
        if (in_array($form_id, array('entry_node_form', 'album_node_form'))) {
          $form['dff_custom']['#type'] = 'item';
          $form['dff_custom']['#value'] = '<fb:login-button>Share with Facebook!</fb:login-button><br />If you want to publish this update to your Facebook Wall, click the button abo$
          $form['dff_custom']['#weight'] = -100;
        }
    }

then in a nodeapi insert hook, I check for the flag above, and:


if (isset($node->stream_publish) && $node->stream_publish) {

$attachment = array(
		        'name' => $node->title,
		        'href' => url($node->path, array('absolute' => TRUE)),
		        'description' => $node->teaser,
		      );
		      
		      $user_message = t('Check out my latest !type on !site...',
		                        array('!type' => $node->type, '!site' => variable_get('site_name', '')));
		      
		      $actions = array();
		      
		      $actions[] = array('text' => t('Read More'),
		                         'href' => url($node->path, array('absolute' => TRUE)),
		      );
		      
		      fb_stream_publish_dialog(array('user_message' => $user_message,
		                                     'attachment' => $attachment,
		                                     'action_links' => $actions,
		                               ));
}

?>

Dave Cohen’s picture

I'm not sure what was broken about your code. There's code in modules/fb/contrib/fb_example.module that does something similar.

You're better off using theme('fb_login_button', 'Connect'); rather than the fb:login-button markup. The former will include extended permissions (if any are configured, and you would want to prompt for stream_publish).

kevinquillen’s picture

Yeah, I don't know. It was working fine up until a month ago, who knows.

Also, one of the FB login methods tries to hijack the entire session without logging in as a valid Drupal user (or registering it, if new). So I ditched using FB Connect.