Skip to content

Flask based API to tweet most recent post on Wix Blog

Notifications You must be signed in to change notification settings

vbdane/wix-blog-twitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

wix-blog-twitter-flask-api

Flask based API to automatically tweet latest post on Wix Blog

About

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.

Prerequisites

• 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. )

Preparation

The main.py file has certain empty variables. You'll have to enter the corresponding values.

1. Domain

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'

2. Key

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.

3. Twitter Credentials

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


Deployment

Hosting

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)

API Call

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.

Releases

No releases published

Packages

No packages published

Languages