This project automatically posts images to Facebook by getting memes or any images from reddit. See a example page.
Before you begin, ensure you have met the following requirements:
- You have installed the latest version of Python and pip. You can download Python from here and pip is included in Python 3.4 and later versions.
- You have a Windows/Linux/Mac machine.
- You have read Facebook Graph API documentation.
- You have a Facebook account and have access to a Facebook page where you can post images.
- You have a Reddit account with a developer application set up to get the
reddit_key
andreddit_secret
. You can create a new application from here. - (optional) You have set up a Discord webhook to get the
main_messages
andlogs
webhook URLs. You can read about setting up Discord webhooks here.
git clone https://github.com/phuyalgaurav/facebook-auto-post.git
cd facebook-auto-post
python3 -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install -r requirements.txt
Create a .env
file in the root of the project and add your environment variables:
main_messages=<your_main_messages_webhook_url>
logs=<your_logs_webhook_url>
reddit_key=<your_reddit_key>
reddit_secret=<your_reddit_secret>
reddit_user_agent=<your_reddit_user_agent>
overlay_path=<your_overlay_path>
page_token=<your_page_token>
use_webhook=<True_or_False>
Replace <your_main_messages_webhook_url>
, <your_logs_webhook_url>
, <your_reddit_key>
, <your_reddit_secret>
, <your_reddit_user_agent>
, <your_overlay_path>
, <your_page_token>
, and <True_or_False>
with your actual values.
To run the script, use the following command:
python main.py
This should run the script for 23-24 hours you can modify this byt modifying main.py at line 81 :
# This posts the images to facebook with a sleep time that is distributed evenly throughout the day
post_for_fb(posts, (60 / (len(posts) / 23)) * 60, page_token)
# This posts the images to facebook every 60 sixty seconds
post_for_fb(posts, 60, page_token)
Contributions are welcome! To contribute:
-
Fork this repository.
-
Create a new feature branch.
-
Commit your changes.
-
Push the branch.
-
Open a pull request.
:)
- Thanks to the Facebook Graph API for providing the API to post images.
- Thanks to the PRAW library for making it easy to interact with the Reddit API.
This project is licensed under the terms of the MIT license. See the LICENSE file for details.
- Gaurav Phuyal - phuyalgaurav