Due to EU GDPR, Facebook has disabled this function and the app that is created can no longer be used as is for this purpose. This means this tutorial is no longer useful
Summary
As many sections don't use any sophisticated tool for events management, the goal is to integrate Facebook Events from section FB page into Satellite webpage so it could be later used as source feed for ESNapp, listed in calendar etc. The main idea is this happens automatically so Event coordinator doesn't have to enter the Event twice.
Approach
Since Facebook Graph API 2.0 it is impossible to create Events on FB using this API, therefore the only way to integrate Satellite and FB is to get Events into Satellite. This approach does however have some negative aspects meaning we'll not be able to fully use Satellite event feature including Price, Event type, What's included etc. The only available data are listed here on FB Graph API page. On the other hand it allows us to use every FB Event as fully qualified node in Satellite - therefore use them in views, ESNapp etc. We'll try to keep this guide simple, of course extensions are possible.
Requirements
- Cron configured in order to keep content updated automatic
- Module Feeds Admin UI enabled (already part of satellite, just enable it)
- Module Feeds Tamper installed and enabled
- Module Feeds: Facebook parser installed, enabled and updated with new fields (see below in part 2)
1) Facebook part
To get data from your public Profile or Facebook Page, you need to get the feed from Facebook Graph API. To get that, you need an access token. To get that, you need to create a FB App. To do that, you need to register your account as FB Developer. But don't worry, it's a 5 minutes piece of cake job.
- Register your FB account as FB Developer - just login to developers.facebook.com (and get back there if FB sends you anywhere else), note it doesn't have to be connected in any way with the Page as you're getting public information.
- Create new app - Advanced setup > fill in the name ie. "My page feed", Category: Apps for Pages
- Find your FB Page ID for the Page you want to get Events from, in case it's not in URL, use some online tool for that
- Open Graph API Explorer, choose your new app as Application (top right corner) and hit Get App Token (this one never expires)
- To test your feed copy your Page ID into the Graph API Explorer and add /events, after submitting the form you should see feed with all your FB Events and that's it for Facebook part
Your Feed URL, which is the source we'll use in Satellite, consist of your Page ID, Access Token and fields you want to get - as there is no image in default set (full list of fields is available on Graph API).
Fields we need are following ones: id, name, description, place, start_time, end_time, cover
So the URL might look like this:
replace {fb_page_id} and {access_token} with your information
2) Satellite part
We'll fit the content of our FB feed into already existing content type - Event. This way everything else is already set in Satellite so there is no need to create views or new blocks in homepage.
To process the feed in Satellite we need to enable Feeds Admin UI module which is already installed in satellite. Next module we need is Feeds Tamper and Feeds Tamper Admin UI (download and enable both). Last step is to install and enable Feeds: Facebook parser module, which unfortunately we need to update in order to fit our needs as the developer is the most active one - but don't worry, the module is just set of parameters so anyone can easily adjust it (download already modified module here - install and enable it).
- You can either set importer manually or use Structure > Feeds Importers > Import Importer option and paste this code into the big textfield - if succeed, skip down to point 10 - Converting countrycode, or continue with step 2 if import is not available
- Navigate yourself to Structure > Feeds importers > Add importer
- Create new importer and name it to fit your needs ie. FB Page events importer
- No need to change anything on first page, just check frequency of update - also depends on your cron settings, hit Save
- Set Fetcher on HTTP Fetcher and leave its settings all empty, hit Save
- Select Facebook Parser as Parser - thats the one we installed, hit Save
- Set the Processor as Node processor - we want to create nodes (Events) from feed, hit Save
- In Settings for Node processor set
- Bundle to Event
- Updating of existing nodes depends on your need, remember Satellites Events will not be updated in case of ie. time update on Facebook if you set this not to update, so we recommend Update existing nodes
- Text format as Plain text
- You can also set way of updating Events not present in FB feed, authoring information and node expiry
- Hit Save
- The Mapping
Source column is the one from Feed, Target is the one in Satellite Event. Remember you'll need at least one field as unique so Satellite doesn't import nodes already imported, then set pairs as follows.- Name > Title
- Description > Body
- Post id > GUID and set it as unique
- Start date > Date: Start
- End date > Date: End
- Link to event > More information: URL
- Name > More information: Title
- Event Cover > Image: URI
- Event Cover (cover) > Spotlight Image: URI (field_image_spotlight:uri)
- Event Place - name > Place
- Event Place - street > Address: Thoroughfare (Satellite 4.5+)
- Event Place - city > Address: Locality (Satellite 4.5+)
- Event Place - zip > Address: Postal code (Satellite 4.5+)
- Event Place - country > Address: Country (Satellite 4.5+)
- Start date > Published date (created)
- Set converting plugin for countrycode - in your feed importer navigate to Tamper setting and add plugin Other: Country to ISO code for Address: Country field
- Import your nodes for first time - Structure > Feeds importers, hit Import link hidden in little text above (you can also navigate yourself to yoursite.tld/import), find your new importer ie. FB Page events importer.
- Now it's time to enter your Facebook Feed URL we prepared earlier and hit Import. This should create initial set of your FB Events and also run next time Cron is triggered.
- Check out your Cron settings in Configuration > System > Cron. In order to update your feed regularly, Cron has to be enabled or triggered another way. Note that you can always refresh your Events by manually running the Cron (under the home icon in admin menu).
That's it, you have your Facebook Events auto-updated in Satellite.
Please feel free to contact IT Committee with any questions or notes that could improve this guide.
Workaround about cover images problem while importing from FB page
Pre-requisite: Facebook page events import set up according to tutorial: https://helpcenter.esn.org/tutorial/facebook-events-satellite
Issue: the cover images of the events are not imported; sometimes during manual input there are error messages about it (screenshot attached)
Explanation: the issue is with Drupal Feeds, patch submitted by Zoltan Tudlik (https://www.drupal.org/node/2856478) but hasn't implemented yet.
Workaround:
- In your server (e.g. via FTP) go to profiles/satellite/modules/contrib/feeds/plugins/ folder.
- Find file FeedsParser.inc and make a backup copy of it, say, FeedsParser.inc.bak - you will need it if something goes wrong.
- Edit the FeedsParser.inc file: change the line (it is approximately line number 467)
if (drupal_realpath($this->getSanitizedUri())) {
into
if (!file_create_url($this->getSanitizedUri())) { - Save changes and close.
- Clear caches: in Satellite of your website go to Administration > Configuration > Development > Performance and press Clear all caches.
- Manually run import of the events from Facebook:
- go to Administration » Structure, find in the text link Import (usually points to
/import) and press it; - click on your importer;
- press Import button.
- go to Administration » Structure, find in the text link Import (usually points to
That's it. However sometimes, if you already events previously imported from Facebook, you might need to manually remove them from Satellite (at least those events you want to re-import) and repeat Step 6 above.
Note that after updates of FeedsParser.inc, you changes can disappear and you will need to re-do the steps again!