[wp-hackers] Facebook Events Integration

Eric Mann eric at eamann.com
Wed Mar 10 01:53:15 UTC 2010


I had a recent request from a client to integrate their WordPress event
calendar (Event Calendar 3 plug-in by Alex Tingle) with Facebook's native
event system.  I've managed to create a server application that will create
an event when you make a request, but it's not working the way I want things
to.

 

The way things should work:

.         User creates an event in WordPress

.         Plug-in automatically posts the information to the Facebook
application

.         Facebook application creates a new event assigned to the user's
Facebook account

 

Ideally, this should all happen behind the scenes.  I've created a system
that will take the posted information and create an event, but I'm running
into a handful of issues with this:

1)      This is the biggie . Even though the user is logged in to Facebook,
WordPress isn't.  So when WP tries to post data to the FB application,
everything fails.  Unfortunately I don't know how to trick the servers into
recognizing one another or how to get WordPress to authenticate as a
Facebook user.  If I can't do that, I can't create the event . any ideas?

2)      I've been using wp_remote_post() to send the information to Facebook
. but I'm not 100% sure I'm using the function correctly, and it's not very
well documented in the source code.  The code I'm using is below . I've
tried to copy the in-source examples of wp_remote_post(), but I know I could
benefit from some additional guidance from those of you with more experience
in cross-server communications.

 

My code:

 

<?php

$array = array( 'start_time_hour' => 10, 'start_time_minute' => 0,
'start_time_month' => 3, 'start_time_day' => 10, 'start_time_year' => 2010,
'end_time_hour' => 11, 'end_time_minute' => 0, 'end_time_month' => 3,
'end_time_day' => 10, 'end_time_year' => 2010, 'category' => 1, 'location'
=> 'My House', 'host' => 'Eric Mann', 'name' => 'Test Meeting Entry');

 

$request = wp_remote_post('http://apps.facebook.com/eventcalendarthree/',
array('method' => 'POST', 'request' => serialize($array)));

if(is_wp_error($request)) {

                echo $request->get_error_message();

}

?>

 

The Facebook application is meant to take this information and call the FB
API directly (with the appropriate api and secret key).  I've tested it by
inputting information directly via $_GET[] (url query strings) and
converting the GET variables into POST variables before parsing . so I know
on the FB side that things are working.  It's the WP side of things where
I'm having issues.

 

I don't know if anyone's handled this particular situation in the past, but
if you have I'd love to hear your take on things.  Ideas?

 

 

Eric Mann

www.eamann.com

 

 



More information about the wp-hackers mailing list