python - 通过 python 脚本发送短信
问题描述
在下面的程序中,我试图向选定的号码发送短信。使用 sql 查询从表中选择数字,然后将其存储在 pr 中。在有效载荷中,我不想直接输入数字,而是想用pr一一发送短信。但在这种情况下,它显示数字丢失。有什么办法吗?
import sqlite3
import requests
conn=sqlite3.connect("Face.db")
cmd="select mnumber from peoples where presence=1"
cursor=conn.execute(cmd)
for row in cursor:
pr=int(row[0])
url = "https://www.fast2sms.com/dev/bulk"
payload = "sender_id=FSTSMS & message=good morning & language=english & route=p & numbers=pr"
headers = {
'authorization': "zg6YJqFs2wCbPGM9H5p4QOiDlSAca7KvIhWrLxNmEX0RoVBdkefWOGmNVHeR9d6lM8Kzn07gQPBhusFU",
'Content-Type': "application/x-www-form-urlencoded",
'Cache-Control': "no-cache",
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
conn.commit()
conn.close()
解决方案
改变这个
"sender_id=FSTSMS & message=good morning & language=english & route=p & numbers=pr"
对此
"sender_id=FSTSMS & message=good morning & language=english & route=p & numbers="+pr
以上应该工作。我注意到您在字符串中添加了 pr
推荐阅读
- android - 无法在 genymotion 中安装 apk
- objective-c - 如何检查当前加载的视图控制器?(ObjC + 斯威夫特)
- android - 带有 Android 皮肤的模拟器上的右侧菜单按钮
- java - 如何通过 http 更有效地下载大文件?
- linux - 从 Ubuntu 18.04 升级到 18.10 后,我收到 Sendmail-Base 错误
- php - 使用 AJAX 定期将数据重新发布到 Laravel 后端时出现问题
- xamarin - 如何在主详细信息页面中自定义标签页?
- php - 如何从网站的谷歌分析中查询数据?
- android - Firebase Cloud Firestore 代码
- java - 如何为每个对象创建一个对象集合