Using your sample code as a start, I have just about got a fully-Drupalized version. If you are interested in my contributing it back, I'd be happy to.

One question though. In the sample, you have if (isset($GLOBALS['fb']) && fb_facebook_user()). On my site, the global is indeed set, but "fb_facebook_user" is returning null. I cannot locate that function (it was late when I was looking). What is that supposed to do? I know I was logged into FB at the time I was testing.

Comments

nancydru’s picture

Excuse me, it is actually $fb->get_loggedin_user that I cannot find.

Looking at the comments Unlike fb_get_fbu(), works only on canvas pages I would think I don't need that since I am using the stream method.

summit’s picture

Subscribing, interested in Drupal-Facebook.
Nancy, great if you contribute your code. Can look into it than!
greetings, Martijn

nancydru’s picture

Dave Cohen’s picture

get_loggedin_user is part of facebook's php sdk. In the version for DFF 2.0, at least. In the newer php sdk (DFF 3.x), that function no longer exists.

nancydru’s picture

Well, it appears to not know who I am, even though I am logged into FB on another tab. Do I need to provide it with a FB ID?

Dave Cohen’s picture

It should return your facebook id, only if you've authorized the app.

nancydru’s picture

How do I authorize the app if it has never tried to publish?

This will not work if the 400 users are individually going to have to pre-authorize an app so that they can post. It would probably be okay on their first attempt at posting.

Dave Cohen’s picture

Authorizing the app is what happens when user clicks the facebook connect button.

You might be more interested in a share button or a like button. You can have either of those without a full-fledged application that the user has to authorize.

nancydru’s picture

There is already a share button for several social sites, including Facebook. What they are looking for is a check box that they can check during node creation that will automatically publish the node (or not, as they choose). These people are quite lazy; they don't want to create and node and then share.

I haven't even seen a Connect button...

nancydru’s picture

The only "Connect" setting I see is "Add to login form," which we don't use. Our login comes from the main site (we are on a sub-domain) and happens under the covers.

Dave Cohen’s picture

I think you're trying to do something that can only be done with an application. And possibly only with the write to stream extended permission (writing with no dialog ever appearing).

You should read up on http://developers.facebook.com/ about their APIs and what is possible. If it is possible, hopefully Drupal for Facebook can make it easier to implement.

nancydru’s picture

Okay. I thought maybe that sample code in the documentation was supposed to be close to what I wanted. I have thought about just redirecting to the equivalent of the "Share" link.

I don't mind making them go through that FB authorization the first time they post, but to ask them to pre-authorize is something that I think just won't happen. These people can be very lazy and very arrogant.

WildBill’s picture

"I don't mind making them go through that FB authorization the first time they post, but to ask them to pre-authorize is something that I think just won't happen. These people can be very lazy and very arrogant."

Those are the same thing. Doing the FB authorization the first time is the same as authorizing the app.

nancydru’s picture

That's fine with me; FB users should be pretty much used to doing that. I got the feeling from Dave that there was some process they would have to go through before they could try to post.

So, I think the big hurdle I have now is linking my Drupal user to his/her FB user. Logging in through FB is out of the question.

BMorse’s picture

We've been trying to get this to work on a test site. We have FB Connect button on login and there is a Share on Facebook checkbox on the node creation. But it doesn't actually seem to post to the user's stream. Anyone get this working?

nancydru’s picture

BMorse’s picture

Requires the 3.x dev version I assume as it's in that thread. But when we installed that version we got an error for the whole site.