【问题标题】:How can I send a message to specific users phone by using Python?如何使用 Python 向特定用户的手机发送消息?
【发布时间】:2017-01-15 19:33:38
【问题描述】:

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

我分享了我的一部分代码:

Enter image description here

【问题讨论】:

  • 我们可以看看你尝试了什么吗?这对我来说有点未经研究,我们确实鼓励这里的发帖人先尝试解决他们的问题。
  • 请将代码作为文本添加到您的问题中,而不是图像!几乎不可能破译。只需将代码缩进四个空格,或使用编辑框上方的“{}”按钮选择代码。
  • 不,您没有共享您的代码的一部分。您将代码复制到 Word 中,截取了极低分辨率的屏幕截图,然后发布。 复制您的代码,edit您的问题,粘贴代码,突出显示它,然后按{ }代码格式化按钮。

标签: python sendmessage


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    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")
    

    【讨论】:

      猜你喜欢
      • 2014-08-14
      • 2015-04-27
      • 1970-01-01
      • 1970-01-01
      • 2019-07-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多