A Python library for posting content to multiple social media platforms including Bluesky, Mastodon, Facebook, LinkedIn, Instagram, and Threads.
- Post text content
- Post images with captions
- Post links with previews (where supported)
- OAuth authentication support for Facebook and LinkedIn
- Environment variable based configuration
- Error handling for each platform
- Clone this repository
- Install dependencies:
pip install -r requirements.txt- Copy
.env.exampleto.env:
cp .env.example .env- Set up your environment variables in
.env:
BLUESKY_HANDLE: Your Bluesky handleBLUESKY_PASSWORD: Your Bluesky password
MASTODON_ACCESS_TOKEN: Your Mastodon access tokenMASTODON_API_BASE_URL: Your Mastodon instance URL
FACEBOOK_ACCESS_TOKEN: Your Facebook access tokenFACEBOOK_PAGE_ID: Your Facebook page ID (if posting to a page)
LINKEDIN_CLIENT_ID: Your LinkedIn application client IDLINKEDIN_CLIENT_SECRET: Your LinkedIn application client secretLINKEDIN_ACCESS_TOKEN: Your LinkedIn access token
INSTAGRAM_USERNAME: Your Instagram usernameINSTAGRAM_PASSWORD: Your Instagram password
THREADS_USERNAME: Your Threads usernameTHREADS_PASSWORD: Your Threads password
For Facebook and LinkedIn, you can use OAuth authentication:
- Create a Facebook/LinkedIn application in their respective developer consoles
- Get your client ID and client secret
- Set up a redirect URI in your application settings
- Use the authentication methods:
poster = SocialMediaPoster()
# LinkedIn OAuth
poster.authenticate_linkedin(
client_id='your_client_id',
client_secret='your_client_secret',
redirect_uri='your_redirect_uri'
)
# Facebook OAuth
poster.authenticate_facebook(
client_id='your_client_id',
client_secret='your_client_secret',
redirect_uri='your_redirect_uri'
)from social_media import SocialMediaPoster
# Initialize the poster
poster = SocialMediaPoster()
# Post text to all platforms
poster.post_text("Hello, world!")
# Post text to specific platforms
poster.post_text("Hello, world!", platforms=['bluesky', 'mastodon'])
# Post image with caption
poster.post_image(
"Check out this photo!",
"path/to/image.jpg",
alt_text="Description of the image"
)
# Post link with text
poster.post_link(
"Check out this article!",
"https://example.com/article"
)- Never commit your
.envfile to version control - Keep your API keys and tokens secure
- Use environment variables in production
- Consider using a secrets management service in production
- Instagram doesn't support text-only posts
- Instagram doesn't support clickable links in posts
- Some platforms may have rate limits or other restrictions
This project is licensed under the GNU General Public License v3 - see the LICENSE file for details.