Wix Blog Integration for Alwrity
This integration allows you to publish blog content from Alwrity directly to your Wix site using the Wix REST API.
Features
- Blog Post Management: Create, update, and delete blog posts
- Media Management: Upload images and other media files
- SEO Optimization: Comprehensive SEO settings and analysis
- Category Management: Create and manage blog categories
- Markdown Support: Write in markdown and publish as HTML
- Streamlit UI: User-friendly interface for publishing
Prerequisites
Before using this integration, you'll need:
- A Wix site with the Blog feature enabled
- Wix API credentials (refresh token and site ID)
- Python 3.7+ with required dependencies
Getting Wix API Credentials
To use this integration, you need to obtain a refresh token and site ID from Wix:
- Create a Wix Developer Account:
- Go to Wix Developers and sign up or log in
- Create a new OAuth app
- Configure OAuth App:
- Set a name and description for your app
- Add redirect URLs (e.g.,
https://localhost:3000/oauth/callback) - Save the app and note the App ID and App Secret
- Get a Refresh Token:
- Follow the OAuth flow to get an authorization code
- Exchange the code for an access token and refresh token
- Detailed instructions: Wix OAuth Documentation
- Get Your Site ID:
- Log in to your Wix account
- Go to your site's dashboard
- The site ID is in the URL:
https://manage.wix.com/dashboard/{SITE_ID}/home
Installation
The Wix integration is included with Alwrity. No additional installation is required.
Usage
Using the Streamlit UI
- Navigate to the Wix integration in the Alwrity UI
- Enter your Wix refresh token and site ID
- Fill in the blog details and content
- Click "Publish to Wix"
Using the Python API
from lib.integrations.wix_integration import WixIntegration
# Initialize the integration
wix = WixIntegration(
refresh_token="YOUR_REFRESH_TOKEN",
site_id="YOUR_SITE_ID"
)
# Publish a blog post
result = wix.publish_blog_post(
title="My Blog Post",
content="# Hello World\n\nThis is my blog post.",
is_markdown=True,
tags=["example", "blog"],
categories=["Technology"],
publish=True
)
# Get the published post URL
post_url = result.get("post", {}).get("url")
print(f"Published at: {post_url}")
Using the Command-Line Interface
# Set environment variables
export WIX_REFRESH_TOKEN="YOUR_REFRESH_TOKEN"
export WIX_SITE_ID="YOUR_SITE_ID"
# List blog posts
python -m lib.integrations.wix_cli list-posts
# Publish a blog post
python -m lib.integrations.wix_cli publish-post \
--title "My Blog Post" \
--content-file blog.md \
--is-markdown \
--tags "example,blog" \
--categories "Technology"
# Generate an SEO report
python -m lib.integrations.wix_cli seo-report \
--title "My Blog Post" \
--keywords "example,blog,technology"
API Reference
WixIntegration
The main integration class that provides high-level methods for working with Wix blogs.
Methods
publish_blog_post(title, content, ...): Publish a blog postupload_media(file_path, ...): Upload a media fileget_seo_report(post_id, target_keywords): Generate an SEO reportlist_blog_posts(limit, offset, ...): List blog postslist_categories(): List blog categoriescreate_category(name, description): Create a blog categoryget_post_by_id(post_id): Get a blog post by IDget_post_by_title(title): Get a blog post by titledelete_post(post_id): Delete a blog post
WixAPIClient
Low-level client for interacting with the Wix API.
WixBlogManager
Handles blog content management, including markdown processing and image handling.
WixSEOOptimizer
Provides SEO analysis and optimization for blog posts.
Error Handling
The integration includes comprehensive error handling:
- API errors are logged with detailed information
- Authentication errors provide clear guidance
- File handling errors include path information
- Network errors include retry logic
Best Practices
- Store credentials securely:
- Use environment variables or a secure credential store
- Don't hardcode credentials in your code
- Optimize images before upload:
- Compress images to reduce file size
- Use appropriate image formats (JPEG for photos, PNG for graphics)
- SEO optimization:
- Use the SEO report to improve your content
- Include relevant keywords in titles and headings
- Add alt text to all images
- Content management:
- Use categories and tags consistently
- Include featured images for better visual appeal
- Write clear, concise meta descriptions
Troubleshooting
Common Issues
- Authentication Errors:
- Ensure your refresh token is valid
- Check that your site ID is correct
- Verify that your app has the necessary permissions
- API Rate Limits:
- The Wix API has rate limits that may affect bulk operations
- Add delays between requests if you're publishing many posts
- Image Upload Issues:
- Check that the image file exists and is readable
- Verify that the image format is supported (JPEG, PNG, GIF)
- Ensure the image file size is within Wix limits
- Content Formatting Issues:
- If using markdown, ensure it's valid
- Check for special characters that might cause issues
- Verify that HTML content is properly formatted
Getting Help
If you encounter issues not covered here:
- Check the logs for detailed error messages
- Consult the Wix API Documentation
- Contact Alwrity support for assistance
License
This integration is part of the Alwrity platform and is subject to the same license terms.
Acknowledgements
- Wix REST API for providing the API endpoints
- Requests for HTTP functionality
- Markdown for markdown processing
- BeautifulSoup for HTML parsing
- Streamlit for the user interface