Skip to content

Instantly share code, notes, and snippets.

Created June 1, 2016 13:54
Show Gist options
  • Save anonymous/c263c2eec32b4add8fdb1938367927a7 to your computer and use it in GitHub Desktop.
Save anonymous/c263c2eec32b4add8fdb1938367927a7 to your computer and use it in GitHub Desktop.
Send SMS via TextMagic API and Python
# import modules
from textmagic.rest import TextmagicRestClient
import numpy as np #殺雞用牛刀
import pandas as pd #殺雞用牛刀
# run the API of TextMagic
username = <username>
token = <token>
client = TextmagicRestClient(username, token)
def messagetext(name, gender, examTime):
if gender=="M":
suffix="先生"
elif gender=="F":
suffix="女士"
else:
suffix="君"
message = ("%s%s您好,X醫院A部門提醒,明天%04d為您安排blah blah,若無法配合請來電(07)2461357轉8888,謝謝" % (name , suffix, examTime) )
return message
def sendmessage(name, message, phone):
phone= ("886%d" % phone)
message = client.messages.create(phones=phone, text=message)
print("sent a SMS to %s" % name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment