def create(self, request):
        # TODO(winkler) document
        request.full_clean()
        form = request.data
        try:
            messages = format_sms(form['message'])

            #http://api.clickatell.com/http/sendmsg?user=clark&password=4moc@mobile&api_id=3135262&to=16178770502&text=this+is+a+test

            for message in messages:
                params = urllib.urlencode({
                    'user': settings.CLICKATELL_USER,
                    'password': settings.CLICKATELL_PASSWORD,
                    'api_id': settings.CLICKATELL_API,
                    'to': form['recipient_addr'],
                    'text': message
                })
                response = urllib.urlopen(settings.CLICKATELL_URI %
                                          params).read()
            result = succeed('message sent to: %s' % form['recipient_addr'])
        except Exception as e:
            logging.error("Clickatell send fail: %s: %s" %
                          (form['recipient_addr'], e))
            return fail('message send fail: %s' % form['recipient_addr'])
        return result
Пример #2
0
 def create(self, request):
     request.full_clean()
     form = request.data
     result = False
     try:
         messages = format_sms(form['message'])
         for message in messages:
             params = urllib.urlencode({
                     'username': settings.KANNEL_USER,
                     'password': settings.KANNEL_PASSWORD,
                     'to': form['recipient_addr'],
                     'text': message
                     })
             response = urllib.urlopen(settings.KANNEL_URI % params).read()
             logging.info("Kannel response: %s" % response)
         result = succeed('message sent to: %s' % form['recipient_addr'])
     except Exception as e:
         logging.error("Couldn't submit Kannel notification for %s: %s" % (form['recipient_addr'], e))
         result = fail('message send fail: %s' % form['recipient_addr'])
     return result
 def create(self, request):
     request.full_clean()
     form = request.data
     result = False
     try:
         messages = format_sms(form['message'])
         for message in messages:
             params = urllib.urlencode({
                 'username': settings.KANNEL_USER,
                 'password': settings.KANNEL_PASSWORD,
                 'to': form['recipient_addr'],
                 'text': message
             })
             response = urllib.urlopen(settings.KANNEL_URI % params).read()
             logging.info("Kannel response: %s" % response)
         result = succeed('message sent to: %s' % form['recipient_addr'])
     except Exception as e:
         logging.error("Couldn't submit Kannel notification for %s: %s" %
                       (form['recipient_addr'], e))
         result = fail('message send fail: %s' % form['recipient_addr'])
     return result
Пример #4
0
    def create(self, request):
        # TODO(winkler) document
        request.full_clean()
        form = request.data
        try:
            messages = format_sms(form['message'])

            #http://api.clickatell.com/http/sendmsg?user=clark&password=4moc@mobile&api_id=3135262&to=16178770502&text=this+is+a+test

            for message in messages:
                params = urllib.urlencode({
                    'user': settings.CLICKATELL_USER,
                    'password': settings.CLICKATELL_PASSWORD,
                    'api_id': settings.CLICKATELL_API,
                    'to': form['recipient_addr'],
                    'text': message
                    })
                response = urllib.urlopen(settings.CLICKATELL_URI % params).read()
            result = succeed('message sent to: %s' % form['recipient_addr'])
        except Exception as e:
            logging.error("Clickatell send fail: %s: %s" % (form['recipient_addr'], e))
            return fail('message send fail: %s' % form['recipient_addr'])
        return result