如何使用Python向特定用户的手机发送消息?

问题描述 投票:-4回答:2

我已经在PostgreSQL和Python之间建立了关系。我提供了向使用过的Python的用户发送电子邮件的功能。我想向特定用户的手机发送消息。

我分享了部分代码:

Enter image description here

python sendmessage
2个回答
0
投票

您可以使用Amazon SNS服务(简单通知服务)。这是一项REST服务,因此可以以任何语言使用,包括Python。

请参见Using Amazon SNS for User Notifications with a Mobile Phone Number as a Subscriber (Send SMS)


0
投票

[Therearemanyresourcesaround

代码

from smsapi import SmsApi
username = "USERNAME"
password = "PASSWORD"

sms = SmsApi(username, password)

total_points = sms.get_points()['points']
print("You have", total_points, "points left")

cursor = conn.cursor()

list_of_client_numbers = cursor.execute('''SELECT mobNumber FROM clientsTable''')

for eachRecord in list_of_client_numbers:
    sms = sms.send_sms(
          recipient=eachRecord,
          sender_name="YOUR COMPANY NAME",
          message="MESSAGE",
          eco=False)

conn.close()

total_points = sms.get_points()['points'] print("You have", total_points, "points left")
© www.soinside.com 2019 - 2024. All rights reserved.