# PYTHON 簡訊發送 TWSMS 簡訊程式執行時遇到IP權限問題,要先到TWSMS內做設定。  1. 把發送簡訊的電腦加入twsms的信任ip名單中(初次登入會跳出視窗,收驗證碼完成驗證即可)  2. 將電腦的IP加到API來源IP設定裡。  **TWSMS的API只支援單筆簡訊發送,要傳給多人需寫成function,再用迴圈執行。** # sendSMS<span/>.py ```python= # -*- coding: utf-8 -*- import urllib.request def sendSMS(tel): username = "twsms帳號" password = "twsms密碼" mobile = tel message = "SMS_test" msg = 'username='+username+'&password='+password+'&mobile='+mobile+'&message='+message url = 'http://api.twsms.com/json/sms_send.php?'+msg resp = urllib.request.urlopen(url) print (resp.read()) phone=["電話號碼1","電話號碼2"] for i in phone: sendSMS(i) ``` ###### tags: `python` `SMS` `簡訊` `TWSMS`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up