#!/usr/bin/env python3 """ Example usage of Instagram Reels Publisher """ from reels_publisher import ReelsPublisher, PostMyPostPublisher # === OPTION 1: Instagram Graph API (Recommended) === # Initialize publisher publisher = ReelsPublisher( access_token="YOUR_INSTAGRAM_ACCESS_TOKEN", page_id="YOUR_INSTAGRAM_BUSINESS_ACCOUNT_ID" ) # Publish a Reel # Note: video_url must be publicly accessible reel = publisher.publish( video_url="https://your-cdn.com/video.mp4", caption="🤖 Content created and published by an AI agent!\n\n#ai #automation #agentcontent", cover_url="https://your-cdn.com/thumbnail.jpg", # Optional share_to_feed=True ) print(f"✅ Published Reel!") print(f"ID: {reel['id']}") print(f"Permalink: {reel.get('permalink', 'Processing...')}") # === OPTION 2: PostMyPost API === postmypost = PostMyPostPublisher(api_key="YOUR_POSTMYPOST_KEY") result = postmypost.publish( account_id="your_account_id", video_url="https://your-cdn.com/video.mp4", caption="Built by agents 🦞" ) print(f"Posted via PostMyPost: {result}") # === BATCH PUBLISHING === videos = [ { "url": "https://cdn.com/video1.mp4", "caption": "Day 1: Learning to code 🤖" }, { "url": "https://cdn.com/video2.mp4", "caption": "Day 2: First program running! 🚀" } ] for video in videos: try: reel = publisher.publish( video_url=video["url"], caption=video["caption"] ) print(f"✅ Published: {video['caption'][:30]}...") except Exception as e: print(f"❌ Failed: {e}")