current position:Home>Python development alert notification SMS alert

Python development alert notification SMS alert

2022-05-15 03:32:49The sky is broken

 PYTHON Docking verification code SMS interface DEMO Example
This article provides you with PYTHON Language version verification code SMS interface docking DEMO Example

* Interface type : Trigger SMS interface , Support sending verification code SMS 、 Order notification SMS , Holiday blessings, etc .
 * Account registration : Please open an account through this address http://user.ihuyi.com/?exClaO

 * matters needing attention :
*(1) During commissioning , Please use the default SMS content : Your verification code is :【 Variable 】. Please don't leak the CAPTCHA to others .
 *(2) Please use user name And APIkey To call the interface ,APIkey Available at the member center ;
*(3) This code is only for reference of accessing SMS interface , Customers can write their own according to their actual needs

mport urllib.parse
import urllib.request

# Address of the interface 
url = 'http://106.ihuyi.com/webservice/sms.php?method=Submit'

# Define the requested data 
values = {
    'account':'xxxxxxxx',
    'password':'xxxxxxxxxxxx',
    'mobile':'134xxxxxxxx',
    'content':' Your verification code is :7835. Please don't leak the CAPTCHA to others .',
    'format':'json',
}

# Encode the data 
data = urllib.parse.urlencode(values).encode(encoding='UTF8')

# Initiate request 
req = urllib.request.Request(url, data)
response = urllib.request.urlopen(req)
res = response.read()

# Print the results 
print(res.decode("utf8"))

-----------------------------------
#python2

# Interface type : Mutual wireless trigger SMS interface , Support sending verification code SMS 、 Order notification SMS, etc .
# Account registration : Please open an account through this address http://user.ihuyi.com/register.html
# matters needing attention :
#(1) During commissioning , Please use the default SMS content : Your verification code is :【 Variable 】. Please don't leak the CAPTCHA to others .
#(2) Please use  APIID  And  APIKEY To call the interface , Available at the member center ;
#(3) This code is only for reference when accessing the mutual wireless short message interface , Customers can write their own according to their actual needs ;
   
#!/usr/local/bin/python
#-*- coding:utf-8 -*-
import httplib
import urllib
 
host  = "106.ihuyi.com"
sms_send_uri = "/webservice/sms.php?method=Submit"
 
# View user name   Log in to the user center -> Verification code notification SMS > Product overview ->API Interface information ->APIID
account  = " user name "
# Check the password   Log in to the user center -> Verification code notification SMS > Product overview ->API Interface information ->APIKEY
password = " password "
 
def send_sms(text, mobile):
    params = urllib.urlencode({'account': account, 'password' : password, 'content': text, 'mobile':mobile,'format':'json' })
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection(host, port=80, timeout=30)
    conn.request("POST", sms_send_uri, params, headers)
    response = conn.getresponse()
    response_str = response.read()
    conn.close()
    return response_str
 
if __name__ == '__main__':
 
    mobile = "138xxxxxxxx"
    text = " Your verification code is :121254. Please don't leak the CAPTCHA to others ."
 
    print(send_sms(text, mobile))

copyright notice
author[The sky is broken],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/131/202205111539325609.html

Random recommended