
import os
import requests

def send_whatsapp_message(phone_number, message_body):
    token = os.environ.get('WHATSAPP_TOKEN', 'PLACEHOLDER_TOKEN')
    phone_id = os.environ.get('WHATSAPP_PHONE_ID', 'PLACEHOLDER_ID')
    
    # If placeholders are active, simulate the send
    if token == 'PLACEHOLDER_TOKEN':
        print(f"[SIMULATED WHATSAPP] To: {phone_number} | Message: {message_body}")
        return True
        
    # Real API call logic (ready for your Meta keys)
    url = f"https://graph.facebook.com/v18.0/{phone_id}/messages"
    headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
    data = {
        "messaging_product": "whatsapp",
        "to": phone_number,
        "type": "text",
        "text": {"body": message_body}
    }
    try:
        response = requests.post(url, headers=headers, json=data)
        return response.status_code == 200
    except Exception as e:
        print(f"WhatsApp Error: {e}")
        return False
