• 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

    https://www.ads-software.com/plugins/events-manager/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    I wouldn’t recommend modifying any of the em_* database tables directly. It’ll almost certainly cause problems.

    The best way to do it is probably to create an extra meta entry in the wp_postmeta table to create the connection you need.

    Thread Starter fersamp

    (@fersamp)

    Thank you for help.

    One last thing: How can I manually add an event to EM?

    I found this link, https://www.ads-software.com/support/topic/building-an-events-object but it doesn’t work.

    $EM_Event = new EM_Event();
    
    // -- $e is facebook event --
    
    $EM_Event->event_name = wp_strip_all_tags($e->name);
    
    $startDateFb = $e->start_time;
    $endDateFb = $e->end_time;
    
    $dtStart = new DateTime($startDateFb, new DateTimeZone('PST'));
    $dtStart->setTimezone(new DateTimeZone('CET'));
    $EM_Event->event_start_date = $dtStart->format('Y-m-d');
    $EM_Event->event_start_time = $dtStart->format('H:i');
    
    $dtEnd = new DateTime($endDateFb, new DateTimeZone('PST'));
    $dtEnd->setTimezone(new DateTimeZone('CET'));
    $EM_Event->event_end_date = $dtEnd->format('Y-m-d');
    $EM_Event->event_end_time = $dtEnd->format('H:i');
    
    $EM_Event->save();
    Plugin Support angelo_nwl

    (@angelo_nwl)

    sorry at the moment we can’t help with custom coding as per the support policy – https://eventsmanagerpro.com/support-policy/

    Thread Starter fersamp

    (@fersamp)

    -_- sorry but in this post you helped about.
    https://www.ads-software.com/support/topic/building-an-events-object?replies=20

    What is support-policy problem there about creating an event through code?

    I only need to add an event through php…

    There was a third party app that did this when facebook did an api update the author did a few tweaks and then basically abandoned it. If you send me an email I will send you some code to look out. Maybe it will help.

    ron

    info at broadleafpost period com

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Facebook events importing’ is closed to new replies.