Facebook Birthday Events to ICS file converter
Around 20 June 2019, Facebook removed their Facebook Birthday ICS export option.
This change was unannounced and no reason was ever released.
fb2cal is a tool which restores this functionality.
It works by calling various async endpoints that power the https://www.facebook.com/events/birthdays/ page.
After gathering a list of birthdays for all the users friends for a full year, it creates a ICS calendar file which is then stored on Google Drive as a publically shared file. This ICS file can then be imported into third party tools (such as Google Calendar).
The ICS file can also be stored on the local file system.
This tool does not use the Facebook API.
- Facebook account
- Python 3.6+
- pipenv
- Scheduler tool to automatically run script periodically (optional)
- Google Drive API access (optional)
- Clone repo
git clone [email protected]:mobeigi/fb2cal.git
- Rename
config/config-template.ini
toconfig/config.ini
and enter your Facebook email and password (no quotes). - Install required python modules
pipenv install
- Run the script manually:
pipenv run python src/fb2cal.py
- Import the created
birthdays.ics
file into Calendar applications (i.e. Google Calendar)
- Clone repo
git clone [email protected]:mobeigi/fb2cal.git
- Create a Google Drive API credentials
- Visit the Google Drive APIs page: https://console.developers.google.com/apis/api/drive.googleapis.com/overview
- Create a new project (if you don't already have one)
- Enable API (if not already enabled)
- Select API & Services > Credentials from left pane.
- Select Create Credentials > OAuth client ID. Make sure to Configure content screen if you are prompted to do so. For the application type select Other and then enter any name you like (i.e. fb2cal)
- Click Create to create your OAuth client ID credentials
- Download credentials JSON file
- Rename credentials JSON file to credentials.json and put it in the
src
folder - Rename
config/config-template.ini
toconfig/config.ini
and enter your Facebook email and password as well as a name for your calender to be saved on Google Drive. Changeupload_to_drive
toTrue
. Initially, the value for the drive_file_id field should be empty. - Install required python modules
pipenv install
- Run script manually once for testing purposes:
pipenv run python ./fb2cal.py
- Check Google Drive to ensure your ICS file was made.
- Setup Cron Jobs/Task Scheduler/Automator to repeatedly run the script to periodically generate an updated ICS file. See Scheduled Task Frequency section for more info.
- Use the following link to import your ICS file into Calendar applications (i.e. Google Calendar):
http://drive.google.com/uc?export=download&id=DRIVE_FILE_ID
. Replace DRIVE_FILE_ID with the autopopulated value found in yourconfig/config.ini
file.
This tool can be configured by editing the config/config.ini
configuration file.
Section | Key | Valid Values | Description |
---|---|---|---|
AUTH | fb_email | Your Facebook login email | |
fb_password | Your Facebook login password | ||
DRIVE | upload_to_drive | True, False | If tool should automatically upload ICS file to Google Drive |
drive_file_id | The file id of file to write to on Google Drive. Leave blank to create a new file for the first time. | ||
ics_file_name | The name of the file to be stored/updated on Google Drive. | ||
FILESYSTEM | save_to_file | True, False | If tool should save ICS file to the local file system |
ics_file_path | Path to save ICS file to (including file name) | ||
LOGGING | level | DEBUG, INFO, WARNING, ERROR, CRITICAL | Logging level to use. Default: INFO |
If you encounter any issues, please open the config/config.ini
configuration file and set the LOGGING
level
to DEBUG
(it is INFO
by default). Include these logs when asking for help.
Also make sure to check the Caveats section below.
It is recommended to run the script once every 24 hours to update the ICS file to ensure it is synchronized with the latest Facebook changes (due to friend addition/removal) and to respect the privacy of users who decide to hide their birthday later on. Facebook originally recommended polling for birthday updates once every 12 hours based on the X-PUBLISHED-TTL:PT12H
header included in their ICS files.
- Facebook accounts secured with 2FA are currently not supported (see #9)
- During Facebook authentication, a security checkpoint may trigger that will force you to change your Facebook password.
- Some locales are currently not supported (see #13)
- Some supported locales may fail. Consider changing your Facebook language to English temporarily as a workaround. (see #52)
- Duplicate birthday events may appear if calendar is reimported after Facebook friends change their username due to performance optimizations. (see #65)
Contributions are always welcome! Just make a pull request.
GNU General Public License v3.0