class sendSMSTask(): def __init__(self): self.smsConnection=None def login(self,phoneNumber,passWord): print 'SMS login...' self.smsConnection=PyFetion(phoneNumber,passWord,'TCP',debug=False) self.smsConnection.login(FetionOnline) def sendSMS(self,message): print 'Send one SMS at time %s'%(time.strftime('%Y-%m-%d:%H:%M:%S',time.localtime(time.time()))) self.smsConnection.send_sms(message) def logout(self): print 'SMS logout...' self.smsConnection.logout()
class FetionClient: def __init__(self, mobile_num, password): self.phone = PyFetion(mobile_num,password,"HTTP",debug=False) FetionLogin(self.phone) def sendMessage(self, receiver, message): print('trying to send message to %s:(%s)'%(receiver,message)) if receiver==None or receiver=='self' or receiver=='me': if self.phone.send_sms(toUTF8(message)): print("message sent") else: print("error sending message") return if not receiver.isdigit() or receiver.isdigit() and len(receiver)!=11: # sending to a name contactlist = copy(self.phone.contactlist) for i in contactlist: if contactlist[i][0] == '': contactlist[i][0] = i[4:4+9] for c in contactlist.items(): if c[1][0] == receiver: to = c[0] if self.phone.send_sms(toUTF8(message),to): print("message sent") else: print("error sending message") return print("cannot find name %s" % receiver) return #send to a number contactlist = copy(self.phone.contactlist) to='' for c in contactlist.items(): if c[1][1] == receiver: to = c[0] if not to: print("the number is not friend") return if self.phone.send_sms(toUTF8(message),to): print("message sent") else: print("error sending message")
def sendSMS(phone_num,passwd,data): fetion = PyFetion(phone_num,passwd,'HTTP') i = 0 fetion.login(FetionOnline) fetion.send_sms(data) fetion.logout()