Cross-post to Bluesky, Mastodon, Posthaven, Instagram, Facebook and, ugh, Twitter in one fell swoop!
[installation guide is a work in progress!!!]
(You can use Ubuntu on a physical computer, on a virtual machine or in the cloud (Amazon Lightsail etc))
Start by ensuring your system is up to date:
sudo apt update
sudo apt upgrade
Install Python, pip, virtualenv, nginx, and other necessary packages:
sudo apt install python3 python3-pip python3-venv nginx git
First, navigate to a directory where you want to store the application's files. In this example, we will create a new directory called myapps in the home directory, and then navigate into it:
Copy code
cd ~
mkdir myapps
cd myapps
Now, within the myapps directory, clone the "social-cross-post" repository from GitHub to your server. This will create a new subdirectory named social-cross-post containing all the files from the repository:
git clone https://github.com/GanWeaving/social-cross-post.git
Navigate into the newly created social-cross-post directory:
cd social-cross-post
You're now in the directory containing the files of the "social-cross-post" application. All the following commands should be executed within this directory.
Create a virtual environment and activate it:
python3 -m venv venv
source venv/bin/activate
Create a requirements.txt
file with the following content:
pytz
Pillow
Flask
Flask-Session
Flask-APScheduler
Flask-SQLAlchemy
atproto
requests
Mastodon.py
tweepy
requests-oauthlib
Then execute this command:
pip install -r requirements.txt
Get your API keys etc here (of course only those that you need, adapt the code accordingly):
- Bluesky: your username and an app password generated under 'settings' is enough
- Mastodon API: https://docs.joinmastodon.org/api/guidelines/
- Twitter API: https://developer.twitter.com/en/products/twitter-api
- Instagram API: https://developers.facebook.com/products/instagram/apis/
- Facebook Pages API: https://developers.facebook.com/docs/pages/
- Posthaven: use the API of your e-mail provider
And then save them into the config.py file using these variable names (replace Fastmail with your own e-mail provider; the 4 lowercase keys are Twitter-related):
BLUESKY_EMAIL
BLUESKY_PASSWORD
FB_ACCESS_TOKEN
FB_PAGE_ID
INSTAGRAM_USER_ID
USER_ACCESS_TOKEN
MASTODON_ACCESS_TOKEN
MASTODON_API_BASE_URL
FASTMAIL_USERNAME
FASTMAIL_PASSWORD
EMAIL_RECIPIENTS
consumer_key
consumer_secret
access_token
access_token_secret
Also add this to your config.py file:
class Config(object):
SECRET_KEY = os.urandom(24)
SESSION_TYPE = 'filesystem'
VERSION = "1.0."
SQLALCHEMY_DATABASE_URI = 'sqlite:///posts.db'
SCHEDULER_JOBSTORES = {
'default': SQLAlchemyJobStore(url='sqlite:///jobs.db')
}
SCHEDULER_API_ENABLED = True
Use Gunicorn as the WSGI server to serve the Flask app:
gunicorn -w 4 app:app
Create a configuration file for your site in the /etc/nginx/sites-available/
directory and create a symbolic link to it in the /etc/nginx/sites-enabled/
directory.
Here is an example configuration file (replace yourdomain.com
with your domain):
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Enable the configuration and restart nginx:
sudo ln -s /etc/nginx/sites-available/your-config /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
If you want to secure your site with HTTPS, you can use Certbot to obtain a free SSL certificate from Let's Encrypt:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com
Follow the prompts to configure Certbot.
Now, you should be able to access your web application by visiting your domain in a web browser.