title: Sending automatic SMS alerts Python/Django
body: <p>I'm building a website using Django. And I want that users can be able to receive alerts via SMS when new topics are posted.</p>
  
  <p>I tested textlocal but I had an issue when trying to send SMS to multiple numbers (<code>numbers = ['xxxxx','xxxxx']</code>) .(I don't want to use <code>group_id</code>).</p>
  
  <p>Generally I want to be able to do something like this:</p>
  
  <pre><code>numbers = (SELECT number FROM users WHERE SMS_subscribe=1)
  sender = 'mywebsite'
  message = 'Hey, a new topic was posted'
  send_sms(numbers, message, sender)
  </code></pre>
  
  <hr>
  
  <p>My textlocal test code:</p>
  
  <pre><code>#!/user/bin/python
  # -*- coding: utf-8 -*-
  from urllib2 import Request, urlopen
  from urllib import urlencode
  
  def send_sms(uname, hash_code, numbers, message, sender):
      data = urlencode({
              'username' : uname,
              'hash' : hash_code,
              'numbers' : numbers,
              'message' : message,
              'sender' : sender,
              'test' : True
          })
  
  
      #data = data.encode('utf-8')
      request = Request('https://api.txtlocal.com/send/?')
      response = urlopen(request, data)
      return response.read()
  
  
  def just_one_sms_message(message, annonce_link, sender):
      links_len=len(annonce_link) + len(sender) + 1
      sms_max_len = 160 - links_len
      if len(message)&gt;sms_max_len:
          message = message[:sms_max_len-6]+'... : '
      else:
          message += ' : '
      return message + annonce_link + '\n' + sender
  
  
  username = 'xxxxxxx@gmail.com' 
  hash_code = '3b5xxxxxxxxxxxxxxxxxxxxxxxxxxx8d83818'
  numbers = ('2126xxxxx096','2126xxxxx888')
  annonce_link = 'http://example.com/'
  sender = 'sender'
  message = 'New topics..'
  message = just_one_sms_message(message, annonce_link, sender)
  
  resp = send_sms(username, hash_code, numbers, message, sender)
  print resp
  </code></pre>
  
  <p>Executing this code I get this error :</p>
  
  <pre><code>{"warnings":[{"code":3,"message":"Invalid number"}],"errors":[{"code":4,"message":"No recipients specified"}],"status":"failure"}
  </code></pre>
  
  <p>But if I change: <code>numbers=('2126xxxxx096')</code>it works.</p>
  
  <hr>
  
  <p>What is the best way or web service to do this ?</p>