Created
June 1, 2016 13:54
-
-
Save anonymous/c263c2eec32b4add8fdb1938367927a7 to your computer and use it in GitHub Desktop.
Send SMS via TextMagic API and Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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