Sync public facebook page events to Google Calendar

amancevice, updated 🕥 2023-01-12 14:56:45

Facebook Event State Transfer

pypi python pytest coverage maintainability

Sync public facebook page events to Google Calendar.

Prerequisites

Before beginning you will need to create and configure a facebook app and use it to acquire a page access token for Graph API.

You will also need to set up a Google service account to acquire a credentials file to authenticate with Google APIs.

Installation

Install fest using pip:

bash pip install fest

Basic Use

Use clients for facebook's Graph API and Google's Calendar API to create FacebookPage and GoogelCalendar objects, then synchronize:

```python import facebook from googleapiclient import discovery

import fest

Connect to Graph API & Calendar API

graphapi = facebook.GraphAPI('') calendarapi = discovery.build('calendar', 'v3', cache_discovery=False)

Get Page/Calendar objects

page = fest.FacebookPage(graphapi, '') gcal = fest.GoogleCalendar(calendarapi, '')

Sync Calendar <= Page

req = gcal.sync(page, time_filter='upcoming') res = req.execute() ```

Deployment

Several methods of deployment are provided.

AWS

A pair of terraform modules module are provided to deploy this tool as a Lambda function on AWS and invoke it on a cron using CloudWatch.

```hcl

WARNING Be extremely cautious when using secret versions in terraform

NEVER store secrets in plaintext and encrypt your remote state

I recommend applying the secret versions in a separate workspace with no remote backend,

or curating them manually in the console or AWS CLI.

resource "aws_secretsmanager_secret_version" "facebook" { secret_id = module.facebook_gcal_sync.facebook_secret.id secret_string = "my-facebook-app-token" }

resource "aws_secretsmanager_secret_version" "google" { secret_id = module.facebook_gcal_sync.google_secret.id secret_string = file("./path/to/my/svc/acct/creds.json") }

module facebook_gcal_sync { source = "amancevice/facebook-gcal-sync/aws" version = "~> 1.0"

facebook_page_id = "" facebook_secret_name = "facebook/my-app" google_calendar_id = "" google_secret_name = "google/my-svc-acct" } ```

Heroku

A terraform module module is provided to deploy this tool as a Heroku application.

hcl module facebook_gcal_sync { source = "amancevice/facebook-gcal-sync/heroku" app_name = "<unique-app-name>" facebook_page_id = "<facebook-page-id>" google_calendar_id = "<google-calendar-id>" google_credentials_file = "<path-to-google-service-credentials>" facebook_page_token = "<facebook-page-access-token>" }

Alternatively, deploy with one click:

Deploy

Issues

the script syncs only events created by the page

opened on 2019-05-05 17:07:56 by 360fun

EXPECTED BEHAVIOUR sync all events added to my Facebook page (not only the one created by it)

this is how I can add whatever event to my page: image

CURRENT BEHAVIOUR the script synchronize only the events created by the page :(

Releases

5.1.3 2022-11-30 00:18:49

Migrate to pyproject.toml Drop support for Python 3.6 and lower

5.1.1 2020-12-26 22:20:55

Python 3.9 support

5.1.0 2020-05-20 17:17:21

5.0.0 2018-12-15 14:03:18

This release includes major changes the fest API and drastically reduces the scope of the project. Instead of attempting to sync facebook events with multiple targets, the project is now solely concerned with syncing events to Google Calendar.

Additionally, a terraform module is provided to help deploy this tool as a Lambda function on AWS with support to invoke on a cron with CloudWatch.

A heroku terraform module is also planned.

4.1.2 2018-10-31 14:36:05

Security update

4.0.0 2018-08-08 17:45:53

Fixed bug in Tribe (Wordpress) event deletion Use google-auth library for authenticating with Google Calendar Drop support for Python 2 and 3.3

Alexander Mancevice

senior cloud infrastructrician

GitHub Repository

facebook google-calendar heroku aws python