Flask based API to automatically tweet latest post on Wix Blog
This simple flask based API endpoint allows you to tweet your most recent blog-post along with a short summary, automatically (or with one-click). Wix itself doesn't have a (free) integration to support the same action. This script makes use of RSS Feed of your blog and Twitter API to achieve the said functionality.
• RSS Feed enabled on your Wix Blog. Learn how to do that here.
• Twitter Developer Account. Lean how to get on here.
( NOTE: The developer account should be enabled on the same account from which you wish to tweet. )
The main.py file has certain empty variables. You'll have to enter the corresponding values.
There are two references to 'yourdomain' in the script. Replace them with your website's domain. For example if your website is 'https://www.awesomewebsite.com', replace 'yourdomain' with 'www.awesomewebsite.com'
In the TweetProcess class, a variable named 'myhash' is left empty. Insert a string which will act sort of a password for the api endpoint. You'll have to use this string while sending a api call.
After getting a developer twitter account, you'll get access to the required credentials. Fill in the four variables with the same. Learn how to get the credentials here
While you can extract the logic from the script and manually run it everytime you post, that would defeat the entire point of this automation. The best way to make use of this flask based script is to host it on a server (preferably free) and call this API everytime a new blog post is posted. I used PythonAnywhere as it's simple and free.
Refer this article as a guide to deploying it on PythonAnywhere.
Do not forget to install the required packages namely tweepy, feedparser, flask-restful (flask is pre-installed on PythonAnywhere)
If you've hosted your API on PythonAnywhere free account, this is how the API call should look like https://(your-pythonwnywhere-username).pythonanywhere.com/(project-name)/tweeter/(your-key). I prefer having the API call URL as a simple internet shortcut on the devices which I can just click everytime I post.