def check_sms_balance(account, debug=False): client = textmagic.client.TextMagicClient( account[keys.user], account[keys.pw]) balance = client.account()['balance'] if debug: print "Balance is:", balance return balance
def checkbalance(): client = textmagic.client.TextMagicClient(username, password) balance = client.account()['balance'] print balance if balance < credits: client.send("WARNING - Textmagic credit balance below threshold, please top the account", owner) else: sys.exit()
# Use your username and API password to create a client client = textmagic.client.TextMagicClient('your_username', 'your_api_password') # Send a message and store its message id result = client.send("Hello, World!", "1234567890") message_id = result['message_id'].keys()[0] # Now you can retrieve the delivery status using the message id response = client.message_status(message_id) status = response[message_id]['status'] # Replies to your outgoing messages are delivered to your TextMagic Inbox # This is how you receive messages from your Inbox received_messages = client.receive(0) messages_info = received_messages['messages'] for message_info in messages_info: print "%(text)s received from %(from)s" % message_info # Delete a message from your Inbox client.delete_reply(message_info['message_id']) # Get your account balance balance = client.account()['balance'] # Find the country and cost of a telephone number response = client.check_number('44123456789') info = response['44123456789'] country = info['country'] credits = info['price']
# Use your username and API password to create a client client = textmagic.client.TextMagicClient('your_username', 'your_api_password') # Send a message and store its message id result = client.send("Hello, World!", "1234567890") message_id = list(result['message_id'].keys())[0] # Now you can retrieve the delivery status using the message id response = client.message_status(message_id) status = response[message_id]['status'] # Replies to your outgoing messages are delivered to your TextMagic Inbox # This is how you receive messages from your Inbox received_messages = client.receive(0) messages_info = received_messages['messages'] for message_info in messages_info: print("%(text)s received from %(from)s" % message_info) # Delete a message from your Inbox client.delete_reply(message_info['message_id']) # Get your account balance balance = client.account()['balance'] # Find the country and cost of a telephone number response = client.check_number('44123456789') info = response['44123456789'] country = info['country'] credits = info['price']
textmagic_user = raw_input('TextMagic Username > ') textmagic_key = raw_input('TextMagic Key > ') fileout = open(local_dir+'api_keys.nt','w') fileout.write(wolfram_key+'\n'+textmagic_key+'\n'+textmagic_user+'\n') fileout.close() print 'API File was created' print '' # # # # # #Defaulting To Developer Mode When TextMagic API Is Unavailable client = textmagic.client.TextMagicClient(textmagic_user,textmagic_key) try: credit_amount = 'Credits: '+str(client.account()['balance']) except Exception,e: print 'An error ocurred with TextMagic' print 'Defaulting to developer mode' dev_mode = True print 'Please note that certain functions may not work correctly' print '' print '----- Developer Mode -----' print 'Enter a number to "send" messages from' print 'Note that this number must be whitelisted' dev_number = raw_input('>') print '--------------------------' print '' # # #