Integrating with Facebook Events

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Amir Simantov's picture

Is there any way to get events of facebook users/fanpages/groups into drupal?

Thanks

Comments

This would be the most killer

pribeh's picture

This would be the most killer integration with Facebook ever. But no I don't think there currently is. Not Gigya, nor FBConnect or Drupal for Facebook have such an integration.

Wallflux events

eiland's picture

If you want to sync the Facebook events from a Facebook group or page through an ical connection, you should use Wallflux Events.

Giving it another thought...

Amir Simantov's picture

I am not sure that fb gives such an api - it will allow people not to use its interface and they will use commercials. Alternatively, they might put ads inside the data provided (which can be filtered by reading code, so will - again - not be good for fb).

So?...

setup a facebook user

mxmilkiib's picture

setup a facebook user account, subscribe it to the group/whatever. use fbcal.com to generate an ical from the events it is invited to. use the date/Calendar ical import into Drupal.

MilkMiruku

This sounds very promising,

Amir Simantov's picture

This sounds very promising, thanks! I will give it a try and post an update here.

Facebook API - Events.create

Mark_Watson27's picture

http://wiki.developers.facebook.com/index.php/Events.create

Description
Creates an event on behalf of the user if the application has an active session key for that user; otherwise it creates an event on behalf of the application. Applications can create events for a user if the user grants the application the create_event extended permission.

If you are creating an event on behalf of a user, then your application is an admin for the event, while the user is the creator.

You can upload an image and associate it with the event by forming the request as a MIME multi-part message. See photos.upload for details on the message format to use and the supported image types. You can replace or delete images in an event using events.edit.

This method does not require a session key. However if you call this method without an active user session, then your application is both the creator and admin for the event.

fbcal does not seem to work

Amir Simantov's picture

@MilkMiruku:

After several tries, I did not succeed in making it work.

I want it to make a feed, somehow, from iCal, and make nodes out of it, mapping the date to the date CCK field.

Also, I have tried through Google calendar and didn't work (empty calendar).

Amir

OK fbcal works for getting events of users!

Amir Simantov's picture

It does need some tries and errors. I could not, however, get events of groups (don't know yet about FanPage's events).

fbcal seem to stopped working!

Amir Simantov's picture

Hi,

I was using this tool for some weeks very successfully. However, it seems that it is not working anymore - it is like that for a couple of days now.

If i click on "Get your calendar now" button (target url is create.php) it takes me to a blank page addressed as http://www.fbcal.com/create.php?auth_token=[MY_KEY_HERE].

This makes feedapi stop creating new items. If you try to refresh the feed manually you get a "Could not refresh feed" error.

Thanks,
Amir

Use FQL

MikeBC's picture

with the FB php client library and fbconnect drupal module, you can send a FQL query to FB to pull all of the events related to a user or group (haven't tried with fan pages yet). Unfortunately, you need to make your FQL queries "indexable" (whatever that means) which means in practice that to pull events related to a group you also need the uids of all users authorized to create events for that group as well as the gid for the group. I have a model query and some raw php code i will post here tonight (after I'm done upgrading my drupal install) for y'all to look at.

fbcal returned to work...

Amir Simantov's picture

for now :-)

event retrieval code

MikeBC's picture

<?php
$query
= 'SELECT start_time, host, location, eid, name, tagline, creator

FROM event

WHERE creator = [group-id]
    
     AND eid IN (
          SELECT eid FROM event_member
               WHERE (
                    (uid = [uid1])
                    OR (uid = [uid2])
                    OR (uid = [uid3])
                    OR (uid = [uid4])
                )
           )'
;
    try {
     
$rows = facebook_client()->api_client->fql_query($query);
    }
    catch (
Exception $e) {
     
$msg  = 'Exception thrown while using fbconnect_get_connected_friends: @code';
     
$args = array('@code' => $e->getMessage());
     
watchdog('fbconnect', $msg, $args, WATCHDOG_WARNING);
     
    }
asort($rows);
echo
"<br>Count = ". count($rows) . "<br>";
foreach (
$rows as $key=>$row) {
      
$rows[$key]['start_time_x'] = date("M d, Y - h:ma", $row['start_time']);
}

echo
"<pre>";
print_r($rows);
echo
"</pre>";
?>

bracketed items should be replaced with the FB group ID # and uids 1-4 (or however many you need or want) are necessary to make the FQL query indexable -- those uids should be a set of people who are group members and who, among them, were invited to all of the events in question.
For some reason I am getting weird results in the 'start_time_x' field with regards to resolving the start times in human-readable form but I am working on that.

/edit: this won't pick up events associated with the group if the invite list is private

you can use the events api from facebook

dishui's picture

Here is the link to an tutorial on how to use the facebook event api: http://www.phpeveryday.com/articles/Facebook-Programming-API-Events-P852...

This is great dishui

Amir Simantov's picture

I would like to pay for a drupal programmer to make a module out of it - if there is one interested - please contact me.

..and i`m ready to pay you

pyro's picture

..and i`m ready to pay you Amir for this module :)

Bump. Amir, please contact me

pribeh's picture

Bump. Amir, please contact me if you ever get this made.

FBConnect Events module

katbailey's picture

Hey all,
I've written a module for use on lilithfair.com. You can see it in action here: http://lilithfair.com/events/SeattleGeorge-WA/187/lineup
I'm not sure if I'll actually be releasing it as a contrib module but for the time being you can access the code here:
git://github.com/katbailey/fbconnect_events.git

Hope you find it useful!

Katherine

Hai katbailey, What is

pyro's picture

Hai katbailey,

What is purpose of this module? I cant get it to work...

Hi katbailey, I could access

pribeh's picture

Hi katbailey,

I couldn't [edit] access that git url. Also, I can't seem to access lilithfair.com. Is there a chance you could check it? I'm very interested in trying your module out.

Thanks!

Hi pribeh, can you access

katbailey's picture

Hi pribeh,
can you access http://github.com/katbailey/fbconnect_events ?
As for lilithfair.com, it's definitely up and running so I don't know why you can't access it... :-/

Katherine

Great, I can access both now.

pribeh's picture

Great, I can access both now. Thanks. I'll give it a shot!

Cool website by the way.

Sorry - I've been meaning to

katbailey's picture

Sorry - I've been meaning to post some more info on this. The most important thing to note is that there were bugs in the code when I first committed it and posted about it here - so you'll need to get a fresh checkout of it if you were working with the original code I put up.
Now, the way it works - and bear in mind this was built custom for a client and then I genericised it afterwards so it may not be what you're looking for - basically, if you have a node type that has a field called fbeid (field_fbeid), then when you display a node of this type and its fbeid is a valid facebook event id, this module will add event information from fb to your node. It will display thumbnails of attendees (by default it shows 10 but this is a configurable setting), the event title, and, if you are connected via fbconnect and have authorised the app to rsvp to events on your behalf, a sign-up form.
Let me know if you have any more trouble getting this working.

Manual or Automatic?

Amir Simantov's picture

Hi Katherine,

You said: "...when you display a node of this type and its fbeid is a valid facebook event id..."

How do you populate a node with value of the proper fbeid? Manually? Or do you use any feed?

Thanks.

Hi Amir, this module is only

katbailey's picture

Hi Amir,
this module is only concerned with displaying existing events - it does not do creation of events. So if you want to test it, create a content type called e.g. event, with a field_fbeid cck text field. Create a node of this type and put in a valid fbeid in this field. When you view the the node you should see the event information.

Katherine

Fatal error

vhwouter's picture

Hi Katherine,

Any idea why I get this error?

Fatal error: Call to a member function users_isAppUser() on a non-object in \sites\all\modules\fbconnect_events\fbconnect_events.module on line 79

=> line 79: $is_app_user = $fb->api_client->users_isAppUser($fbuid);

I use FBconnect v2.

Grtz

what's the return value of facebook_client() ?

xurizaemon's picture

(from https://github.com/katbailey/fbconnect_events/blob/master/fbconnect_even...)

<?php
     
if (isset($node->field_fbeid) && $fb = facebook_client()) {
       
$fbuid  = fbconnect_get_fbuid();
       
$eid = $node->field_fbeid[0]['value'];
        try {
         
// has this user authorised this app before?
         
$is_app_user = $fb->api_client->users_isAppUser($fbuid);
        }
?>

Try adding dpm($fb); before line 79 (which is $is_app_user ...). Let us know what value you see for $fb at this point.

It looks like facebook_client() has returned some value which evaluates to TRUE, but is not actually a facebook client object (possibly the returned value is intended to convey an error, and the test above doesn't interpret it as such).

At a guess, I'd say your Facebook client may be incorrectly configured, but that's a guess (might be able to help more if you can provide more info). EDIT: I apologise, I'd misread the error. It appears that the $fb object has changed its structure (or perhaps is misconfigured) - you're getting a (possibly) valid $fb back as a client, but this one doesn't have the object $fb->api_client attached. Need more info to debug. (Prob best done in an issue on the module, rather than here on g.d.o.)

Good luck!

If my comments have helped you, please pay it forward!
Use issue queues to discuss module issues - this will help your questions assist others (including yourself!) in future.

Thank you for you quick

vhwouter's picture

Thank you for you quick reply.

I've managed to get the module fully working. This module depends on the FBCONNECT version 1 module, which has an api_client defined.

vhwouter, I know this is an

Junaos's picture

vhwouter, I know this is an old comment, but were you ever able to get this working with v2? If not, were you able to stack v1 and v2?

+

vhwouter's picture

Hi Junaos,

I didn't port it to FBconnect V2. So the downside is that you can't use any fb-module with it that uses the new sdk php librarie.
I'm fairly new to developing modules in drupal. But when I have the time..I'm gonna study it and try to port it to the new version.

Hi Katherine, Is your module

pribeh's picture

Hi Katherine,

Is your module still working now with all the API changes Facebook has made over the last few months.

Thanks,

Thomas

No, this module does not work

handsofaten's picture

No, this module does not work with the newer Graph API. For one thing, anything that looks like this (see line 195):

<?php
$members
= $fb->api_client->events_getMembers($eid);
?>

Would need to be updated to the new API format (in this case):

<?php
$members
= $fb->api('/'.$eid.'/invited');
?>

I'm working on an implementation of it with the new API, but I'm not sure I'll be doing everything the original module did, or in the same ways. In any case, I'll try to post some tips on updating it as I figure things out (I've never actually used Facebook's API before, so I'm learning as I go).

I have this working with

handsofaten's picture

I have this working with Graph API, and the Drupal for Facebook module (as opposed to the Facebook Connect module). The reason for the change of dependencies is that the Facebook Connect module doesn't allow you to customize extended permissions requests from the admin settings, which I wanted to be able to do. If anyone wants me to post my code, I could fork Katherine's module on git and post my changes, which aren't drastic.

havent worked with the Drupal

vhwouter's picture

havent worked with the Drupal for facebook module.. but I'm definitely interested!
nice job!

Definitely interested

dipen chaudhary's picture

Hey,

I will soon be starting a project to integrate fb events with DFF and your code will definitely be a good start, I was planning to work it out as sub module of DFF but if you have got it already then I can work to improve it as my scope kind of requires 360 degree treatment. Where do you plan to put up the code, you could either put it on github or roll out a project on drupal.org.

Cheers


Dipen Chaudhary
Founder, QED42 http://www.qed42.com Drupal development

Bump for posting it to

pribeh's picture

Bump for posting it to Drupal.org.

Ok, I have posted my code on

handsofaten's picture

Ok, I have posted my code on github. I was having trouble forking the original, so this is just its own project. It's just as well, since katbailey's version wasn't exactly an active project (but it provided a great starting place for me, as I hope this does for someone else). Check the readme for more info. In my testing it works well with Drupal for Facebook and FB's new API. If someone wants to put this on Drupal.org and think through how it should be designed to be a really useful module, I'd be happy to help out. But for now it just serves my purposes and doesn't allow for much customization without actually changing the code.

https://github.com/handsofaten/fb-events

Thanks Katherine, and good luck everyone!

PS. This is what it looks like on the site I'm developing. You'll have to add some CSS on your own to make it format like this, though.

Logged out view:

Only local images are allowed.

Logged in view:

Only local images are allowed.

Thanks so much for sharing

pribeh's picture

Thanks so much for sharing your work on this handsofaten. And thanks again to Katherine for her original work. I still think this would be great to expand upon a little and putting it up on Drupal.org would be the way to go in that regard. dipen chaudhary, do you have a CVS account and are you looking to possibly become the maintainer of this project if so?

This is great! Yes, I pretty

katbailey's picture

This is great! Yes, I pretty much abandoned that code after putting it up on Github so I'm very happy to see that someone else has picked it up and moved it along. Nice work handsofaten! :-)

Hi handsofaten, it mentions

pribeh's picture

Hi handsofaten, it mentions in the readme for fb_events that any CCK field labeled "field_fbeid" will pick up the event info from Facebook. What kind of CCK field should we be using though? A text field or? Thanks for your help.

Yes, a text field. CCK number

handsofaten's picture

Yes, a text field. CCK number field does not allow enough digits. I believe it needs to allow for 12 chars.

Thanks for responding

pribeh's picture

Thanks for responding handsofaten. I guess I still am a little unsure as to how this works. Am I to input the url of the Facebook created event in the suggested field? Just how am I supposed to link the event from Facebook with the event populated on my site?

Re @ Pribeh

vhwouter's picture

I havent test this version yet..but since it is a port and the variable of the text field is still the same.. this should work:

In the textfield assigned to field_fbeid you put the ID of the event. This ID can be found in the url of the even-facebookpage.

example: http://www.facebook.com/event.php?eid=0000000000&index=1

ID=0000000000

Have Fun and thanks for the port Handsofaten.

Yes, this is correct. Would

handsofaten's picture

Yes, this is correct. Would not be terribly hard to make this more intuitive, but as it stands you just find the eid and enter that number.

Does not render...

starsinmypockets's picture

Hmm..
dpm($members); at the end of hook_nodeapi() returns the list of attendees.. so, the connection with fb is live, however, drupal is not rendering anything... Any thoughts?

Have you checked the tpl

handsofaten's picture

Have you checked the tpl file? My guess is that either the tpl file is not being rendered for some reason, or it's not being appended to $node->content (look at lines 154 - 161 in the module file). Let us know if you find the problem.

Edit: specifically, you could try printing $output and/or $node->content['fb_event'] at the end of the nodeapi function, and make sure there is something there.

RE: Does not render...

starsinmypockets's picture

Because the node was being rendered by Display Suite. Now I need to figure out how to hand the themed output to DS and/or views...

Thanks for the help.

I'm not familiar with Display

handsofaten's picture

I'm not familiar with Display Suite, but integrating this module with Views would be a big step toward making it more viable for the general public.

Rendering through views

starsinmypockets's picture

I'm new to coding, but am going to at least have a stab at this.

As I can best understand it, the approach is to create a CCK field type and attach the themed output to its field array, which would allow the imported event info to be output by Views, Display Suite, etc. It seems like this can be done without messing with the data handling code too much...

If anyone with more experience with module development wants to lend a hand, it would be appreciated.

Great module, but I too am a

mixedfeelings's picture

Great module, but I too am a newbie. has anyone had any luck integrating this with views?

Specifically, I'd like to include the $output in list of events created by a view, so that each event in the list had a row of attendee's photos and the invitation to rsvp. Every attempt to include that in my views .tpl has come up flat.

Any Ideas?

Thanks in advance!

Hi! This is really great! I

Ivo.Radulovski's picture

Hi!

This is really great! I tried the module and everything works fine except the form for submitting the RSVP - its missing.

Ive created a test event: http://drupalskills.com/content/test-event

Can somebody help me? Probably its something small...but I miss it... I use FB 6.x-3.0-rc8

Thanks for the nice work!

-----

Drupal Development by Trio Interactive

Thanks for testing this,

handsofaten's picture

Thanks for testing this, segments. The problem is that $perm_status is not set in the template file. This is the variable that tells the module whether the user has given your FB app permission to RSVP to events. Looking at your site, it seems you haven't asked for this permission when the user first signs up for the app. Go to Admin > Site building > Facebook Applications > List. Edit your application, and look under Facebook Extended Permissions. You want to check RSVP.

I, for one, would really

pribeh's picture

I, for one, would really appreciate that handsofaten. I have a site that I could begin testing it with almost immediately. I'm also actually planning on migrating the site over to Drupal for Facebook (considering the greater complexity it allows for).

Thomas

Amazing stuff

Exploratus's picture

Would be really cool.

Sooo Close!

jbergeron's picture

Hello gang,

First of all, excellent work by all of you in pulling this together. I didn't expect to find it.

I have getting an error when I create and try to view a node that was created using the field_fbeid CCK text field.
Everything seems to have installed smoothly, I set up my app and got my API key but I receive the following error:

Fatal error: Call to undefined function dpm() in /XXXX/drupal-6.14/sites/all/modules/fb/fb.module on line 455

Any thoughts? I have all of the following activated according to the readme
-- Facebook API
-- Facebook Apps
-- Facebook Connect
-- User Management
-- Extended Permissions

thanks!
Jeff

Devel module

DerekAhmedzai's picture

That's function is part of the devel module, and prints variables to the screen.
You could enable the devel module (http://drupal.org/project/devel) or comment out that line.

thanks

jbergeron's picture

Thank you. The word "debug" on that line should have tipped me off. That did clear it up.

Update for latest Drupal for Facebook module

Fr0s7's picture

If you have updated to a recent version of the Drupal for Facebook module (such as 6.x-3.0-rc11), you might be getting an error like this:

Fatal error: Call to undefined function fb_access_token() in /sites/all/modules/handsofaten-fb-events-9af22ee/fbconnect_events.module on line 217

This is because the Drupal for Facebook module has re-named the fb_access_token() function to fb_get_token(); Therefore, you have to change the Facebook Connect Events module to match.

Open up 'fbconnect_events.module', go to line 217, and change this...
$members = $fb->api('/'.$eid.'/attending', array('access_token' => fb_access_token($fb)));

... to this...
$members = $fb->api('/'.$eid.'/attending', array('access_token' => fb_get_token($fb)));

This got me up and running again. Love this module! :)

  • Frost Simula

Is there any reason this

willvincent's picture

Is there any reason this isn't a contrib on drupal.org? Seems like there's a good deal of interest in it. I'd be willing to help maintain it if that's a concern.

Nice to have an issue queue

Fr0s7's picture

I use this module, and I'm okay at tracking down where things are breaking in most modules... even if I'm not familiar with how to fix them. For me, one of the biggest reasons to make this an actual contrib project is so we can track and document separate issues, rather than keeping them all in this thread.

  • Frost Simula

You can submit it

BManuel's picture

Hi,
I guess since no one has submitted it as a contrib module, maybe just ask for permission to do that?
I doubt their will be any resistance to that idea :).
Looks like a really useful module and should not be allowed to rot away somewhere in
the dark.
BM

Do it!

handsofaten's picture

As far as I'm concerned, yes, please do. I won't have time to develop this much more for a while, but I'd be really happy to see someone get some use out of it. I think just updating it for Drupal 7 and moving the output to a block would make it a fairly useful module. Good luck!

Good share. I have Drupal 7

vinoth.3v's picture

Good share.

I have Drupal 7 version of this module.

Vinoth - வினோத்
Tamilnanbargal.com

Please share :)

bogdan.racz's picture

Hello there,

Can you please share a development version of the module for Drupal 7.
I'm am really interested in using it and further develop.

Thanks a lot

HI Drupal 7 version of this

vinoth.3v's picture

HI

Drupal 7 version of this module is available at http://drupal.org/project/fb_event

I like to add someone as maintainer. please see http://drupal.org/node/1239480

Vinoth - வினோத்
Tamilnanbargal.com

D6 > Don't get no data

adrianalbisser's picture

I can't figure out to get this working on my site. I followed the readme.txt and set the module and the permissions as it should be. But by adding an CCK-field all I get back is the eid-number:
Facebook: 315726201895566
It seems like the connection to FB doesn't work. Has anyone else experienced similar problems?
I'm running D6 with all modules up to date.

Facebook API

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: