import requests
def send_sms(api_key, phone_number, message):
url = "https://api.example.com/sms/send"
headers = {
"ContentType": "application/json",
"Authorization": f"Bearer {api_key}"
}
data = {
"phone_number": phone_number,
"message": message
}
response = requests.post(url, headers=headers, json=data)
return response.json()
示例用法
api_key = "your_api_key"
phone_number = "1234567890"
message = "您的验证码是:123456"
response = send_sms(api_key, phone_number, message)
print(response) 这是一个使用Python发送短信的示例代码,您需要将api_key替换为您的实际API密钥,并将phone_number和message替换为您要发送的电话号码和消息内容,您还需要将https://api.example.com/sms/send替换为您使用的短信服务提供商的API URL。


【版权声明】:本站所有内容均来自网络,若无意侵犯到您的权利,请及时与我们联系将尽快删除相关内容!
发表回复