使用Twilio Python SDK向尼泊尔号码发送短信无报错但未收到消息的问题排查求助
Twilio Python SDK向尼泊尔号码发送短信无报错但未收到消息的问题排查求助
大家好,我现在碰到一个棘手的问题:我尝试用Twilio给我的尼泊尔手机号发送短信,运行python sms.py时程序完全没有报错,还正常输出了Message sent successfully!,但我的手机始终收不到这条短信。有没有朋友能帮忙分析下可能的原因?
以下是我的Python代码:
from twilio.rest import Client # Replace these with your actual Twilio credentials TWILIO_ACCOUNT_SID = 'ACebf4aec20249287f6f5ea********' TWILIO_AUTH_TOKEN = '91b077f750dbdd02412*******' TWILIO_PHONE_NUMBER = '+1816371****' RECIPIENT_PHONE_NUMBER = '+977981375****' def send_text_message(message): try: # Create a Twilio client client = Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) # Send the SMS message client.messages.create( to=RECIPIENT_PHONE_NUMBER, from_=TWILIO_PHONE_NUMBER, body=message ) print("Message sent successfully!") except Exception as e: print(f"Failed to send the message: {e}") # Call the function to send the text message message_to_send = "Hello, I am your msg" send_text_message(message_to_send)
这是Twilio后台的日志:
From (US) +1 8163718948 To (NP) +977 9813752995 Region United States (US1) Timestamp Elapsed time Twilio Platform Message Created 14:14:53 GMT+5:45 2025-02-02 — Enqueued 14:14:53 GMT+5:45 2025-02-02 0.05 sec Dequeued 14:14:53 GMT+5:45 2025-02-02 0.09 sec Sent 14:14:53 GMT+5:45 2025-02-02 0.24 sec Carrier Network Delivered 14:15:08 GMT+5:45 2025-02-02 15.33 secs There were no HTTP Requests logged for this event.
备注:内容来源于stack exchange,提问作者Dev
相关产品推荐
相关产品推荐

