3

I'm using twilio as for a mobile verification mechanism, I have no prior experience in using twilio but looking at the sample PHP code I used this one in my code but apparently it's giving me an 400 Bad request HTTP error. Here's the code:

    d = {
        'TO' : '*** *** ****',
        'FROM' : '415-555-1212',
        'BODY' : 'Hello user, please verify your device using                    this code %s' % verNumber
    }
    try:
        print account.request('/%s/Accounts/%s/SMS/Messages' % \
                            (API_VERSION, ACCOUNT_SID), 'POST', d)
    except Exception, e:
        return HttpResponse('Error %s' % e)

verNumber is randomly generated and the receiver's number is validated in twilio.

I follow the exception and found this error

Error 400 The source 'From' phone number is required to send an SMS

What does this mean.?

Thanks.

2 Answers 2

9

Looking at some of the twilio examples from the python libraries I notice that the dictionaries containing the payload are typed in MixedCase whereas you've used UPPERCASE.

The error might be quite straight forward rather than

d = {
    'TO' : '*** *** ****',
    'FROM' : '415-555-1212',
    'BODY' : 'Hello user, please verify your device using this code %s' % verNumber
}

try

d = {
    'To' : '*** *** ****',
    'From' : '415-555-1212',
    'Body' : 'Hello user, please verify your device using this code %s' % verNumber
}

The SMS Quickstart ( in the documentation) supports this idea.

Hope this helps.

Sign up to request clarification or add additional context in comments.

2 Comments

Nice catch Jamie! Can I send you a tshirt from Twilio? If so, email me your address and shirt size to jsheehan at twilio dot com
+John, can I get a Twilio t-shirt?! :)
0

Try http://bitbucket.org/vgavro/django-smsgate/ , you may need to write backend for twilio - but the rest is done for you already.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.