This automation tool is designed to:
- Periodically fetch posts from defined sources.
- Publish new content as tweets via Twitter's API.
- Avoid duplicating posts by storing already published tweets in a database.
This program is useful for automating Twitter accounts to share updates, fetch RSS feeds, or repost curated content.
- Configuration Management: Easily define multiple Twitter accounts and their sources in a JSON configuration file.
- Database Integration: Tracks already published tweets to ensure no duplicates are posted.
- Error Handling with Retry Logic: Handles transient failures gracefully to ensure continuous operation.
- Delay Mechanisms: Avoids rate-limiting and bot detection by introducing sleep intervals between retries and operations.
git clone https://github.com/EricFrancis12/twitter-autoposter.git
cd autoposter
Ensure you have Go installed, then run the following command to build the executable:
make build
Run the following command to create a blank config.json
file at the root of the project:
make create_config
Add your desired twitter account details and sources. Take a look at config.example.json
for the correct format.
make run
The AutoPoster runs in a continuous loop, performing these steps:
- Read Configuration Settings.
- Iterate Over All Defined Twitter Accounts and Their Sources.
- Fetch Content from RSS Feeds or other sources.
- Compare fetched content against the database to check for previously published posts.
- If a new post is found:
- Format and publish the tweet via Twitter's API.
- Save the newly published tweet in the database to avoid duplication.
- Wait (Sleep()) between retries or iterations to avoid API rate limits.
You’ll need these credentials for authentication with the Twitter API:
- API Key
- API Secret Key
- Access Token
- Access Token Secret
NOTE: The Access Token and Access Token Secret need to have read and write permissions to be able to post Tweets (see below screenshot). API permissions are configurable in the X Developer Portal.