在5分钟内用python设置短信API

Digitally connected world use automated messages in heavy way. Bills, rent, One Time Passwords there are unlimited scopes of an Automated text.

数字连接的世界大量使用自动消息。 账单,租金,一次性密码无限范围的自动文本。

Suppose you own a mini store and a new item arrives and you want to notify 50 to 100 of your clients. How would you do?, Easy— Text them, Automatically.

假设您拥有一家迷你商店,并且有一个新商品到达,并且您想通知50到100个客户。 您会怎么做?,轻松—自动给他们发短信。

Lets setup a SMS Client for quick learning, I found this website www.textlocal.in with reasonable prices in India. It is providing Bulk message options.

让我们设置一个SMS客户端以便快速学习,我在印度找到了价格合理的这个网站www.textlocal.in 。 它提供了群发消息选项。

Image for post

Create an Account, They give 10 credits, so lets get trying.

创建一个帐户 ,他们会给10点积分,所以让我们尝试一下。

After Sign-up go to Settings >API > Generate a new API Key and save it somewhere safe. You can allow Specific IPs for security, But lets keep the fields empty for now.

注册后,转到“设置”>“ API”>“ 生成新的API密钥”并将其保存在安全的地方。 您可以允许使用特定IP进行安全保护,但是现在让字段为空。

Image for post
Image for post

Requests will go to link https://api.textlocal.in/{command} with command-name in command and data in headers.

请求将转到链接https://api.textlocal.in/{command} 在命令中使用command-name,在header中使用data

Lets Start Coding Part

让我们开始编码部分

Libraries : For now Just One > “import requests”

图书馆:目前只有“一个”>“ 导入请求”

import requests
url = ‘https://api.textlocal.in/'params = {‘username’:’yourusername@mailid.com’,
‘apiKey’:’yourGenerated-APIKey’
}

Lets write some Functions():

让我们写一些Functions():

def check_balance(url):
url = url+'balance'
response = requests.get(url,params=params)
return response.json()
def send_sms(url,params):
url=url+'send' #Phone numbers inside braces {} in commas
numbers={'9911111xxxx'}
message = {'Hi, This is a Sample message'}
params['numbers'] = numbers
params['message'] = message response = requests.post(url,params=params)
return response.json()
def inbox(url):
url = url+'get_inboxes'
response = requests.get(url,params=params)
return response.json()

Thats it, Code finished!! In 5 minutes you can setup SMS message for single or bulk messages.

就是这样,代码完成了!! 在5分钟内,您可以为单个或批量消息设置SMS消息。

In Next Part I will show you to make a quick app to send message, and OTP confirmation too.

在下一部分中,我将向您展示一个快速的应用程序来发送消息以及OTP确认。

Image for post

到那时,再见!!!! (Till then, Good Bye!!!!)

翻译自: https://medium.com/@abhinavsharma150/set-up-a-text-message-api-with-python-in-5-minutes-fdfc46b744c3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值