Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from twilio.rest import Client | |
| # Twilio credentials (replace these with your actual credentials) | |
| TWILIO_ACCOUNT_SID = "AC6971dea521a411c34e5e9d1fe3553ce0" | |
| TWILIO_AUTH_TOKEN = "c6c9f4708b7dff0c31b56d66620a1a15" | |
| TWILIO_PHONE_NUMBER = "+13613148340" | |
| def send_sms(to, message): | |
| """Send an SMS using Twilio.""" | |
| try: | |
| client = Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) | |
| message = client.messages.create( | |
| to=to, | |
| from_=TWILIO_PHONE_NUMBER, | |
| body=message | |
| ) | |
| return True, f"Message sent successfully! Message SID: {message.sid}" | |
| except Exception as e: | |
| return False, str(e) | |
| def main(): | |
| st.title("📱 Send SMS via Internet") | |
| st.markdown( | |
| """This app allows you to send SMS to any mobile number using the internet. Enter the recipient's number and your message below.""") | |
| with st.form("sms_form"): | |
| recipient_number = st.text_input("Recipient's Mobile Number", placeholder="e.g., +1234567890") | |
| message_content = st.text_area("Message Content", placeholder="Type your message here...") | |
| submit_button = st.form_submit_button("Send Message") | |
| if submit_button: | |
| if not recipient_number or not message_content: | |
| st.error("Please fill in both the recipient's number and message content.") | |
| else: | |
| with st.spinner("Sending your message..."): | |
| success, response = send_sms(recipient_number, message_content) | |
| if success: | |
| st.success(response) | |
| else: | |
| st.error(f"Failed to send message: {response}") | |
| if __name__ == "__main__": | |
| main() | |