I wondered if I could send an SMS from the script.
If you google, it seems that you should use a service called twilio (http://twilio.kddi-web.com/). There is also an API library (https://jp.twilio.com/docs/libraries). Convenient.
So, I tried to use it at once, but it seems that the phone number attached to the free account is not possible. Become a paid member (2000 yen charge). It seems that SMS cannot be used with a Japanese phone number (+81), so purchase an American phone number (+1) for 150 yen per month.
So far, fill in the necessary information in the following script, and hit the command with a bang, A message is sent to the to phone number. (1.5 yen per message)
twilio_sample.py
#!/usr/bin/env python2.7
#-*- coding: utf-8 -*-
from twilio.rest import TwilioRestClient
ACCOUNT_SID = '{ Your Account Sid }'
AUTH_TOKEN = '{Auth Token}'
def main():
'''
'''
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
message = client.messages.create(body='{ message }',
to='{ phone number }',
from_='{ Twilio number }')
print message.sid
if __name__ == '__main__':
main()
Recommended Posts