Facebook events importing
-
Hi,
I need to syncronize my Facebook page Events to Events Manager events.I asked in some forum and they told me that you can’t insert events in Facebook trough code (php, jv etc), now it’s not possible anymore.
So I think I try to do a workaround and I would like to share with you to understand if is practicable:
I installed Facebook Events Importer plugin and it works: it imports facebook events but only like different post, not like events manager events, obviously.
So I would like to intercept data events before that plugin saves them as simple post. Instead, I could save them like Events Manager event using a simple insert to DB.
Here php function that is invoked when plugin “import page events” button is clicked, that is in the file fb_import_action.php of Facebook Events Importer plugin:
$eventResponse = (new FacebookRequest($session, 'GET', '/'.$facebook_page.'/events?fields=place,cover,attending_count,description,end_time,id,name,owner,start_time,ticket_uri,timezone&limit=99'))->execute()->getResponse(); $events = $eventResponse->data; foreach ($events as $e) { $session = FacebookSession::newAppSession(); $venue = (new FacebookRequest($session, 'GET', '/'.$facebook_page.'?fields=phone,photos,username,about,category,cover,emails,general_info,general_manager,location,website&limit=99'))->execute()->getResponse(); $startDate = $e->start_time; $endDate = $e->end_time; $timezone = $e->timezone; $category = $e->owner->category; $event_id = $e->id; $eId = wp_strip_all_tags($e->id); $city = $e->place->location->city; $state = $e->place->location->state; $zip = $e->place->location->zip; $street = $e->place->location->street; $region = $e->place->location->region; $country = $e->place->location->country; $ticket_uri = $e->ticket_uri; $eventImage = $e->cover->source; $name = $e->place->name; $fb_event_uri = 'https://www.facebook.com/events/'.$event_id; $lat = $e->place->location->latitude; $long = $e->place->location->longitude; $venue_name = $e->place->name; $venue_phone = $venue->phone; $venue_desc = $venue->about; $emails = $venue->emails; $username = $venue->username; $emailAddress = $emails[0]; $venue_website = $venue->website; $event_tag = $venue->category;
This is only a code part, it’s too long to paste all.
Here events data are retrieved from facebook page, so I could make an insert query in em_events table.My question is:
Can I add a column to em_events table called “facebook_id” to map events manager events to facebook events?
If not, how can I discern new facebook events from old to avoid duplicate events when import from facebook to wordpress?Thank you guys
- The topic ‘Facebook events importing’ is closed to new replies.