Python-Twilio does not send sms with test credentials.

I created a trial account in twilio and installed twilio using

pip install twilio 

on ubuntu 14.04 LTS.

below is my python code to send sms

 from twilio.rest import TwilioRestClient account_sid = "MY TEST ACCOUNT SID" auth_token = "MY TEST ACCOUNT TOKEN" client = TwilioRestClient(account_sid, auth_token) print "running!!" sms = client.sms.messages.create(body="All in the game, yo", to="+91MYNUMBER", from_="+1MY_TWILIO_NUMBER") print sms.sid print sms.status 

While running this python file, I get below log errors from twilio.

Traceback (last last call): File "/home/software/ws/extra/scripts/test.py", line 40, from _ = "+ 1MY_TWILIO_NUMBER") File "/usr/local/lib/python2.7/ dist-packages / twilio / rest / resources / sms_messages.py ", line 167, in the creation return self.create_instance (kwargs) File" /usr/local/lib/python2.7/dist-packages/twilio/rest/resources/ base.py ", line 365, in the file create_instance data = transform_params (body)) File" /usr/local/lib/python2.7/dist-packages/twilio/rest/resources/base.py ", line 200, in request resp = make_twilio_request (method, uri, auth = self.auth, ** kwargs) File "/usr/local/lib/python2.7/dist-packages/twilio/rest/resources/base.py", line 164, in make_twilio_request uri = resp.url, msg = message, code = code) twilio.rest.exceptions.TwilioRestException: HTTP error 400: phone number + 1MY_TWILIO_NUMBER was not It is a valid phone number or short code for your account.

I checked that my number has the ability to voice, SMS and MMS.

I checked this error on here . then I tried with the number +15005550006 , it works, but I never get sms on my mobile phone. The message was sent to a queue that is never processed.

 runnnign!! SM3f51b1c3e5ad43d38bd548cfada14175 queued 

What am I missing? why i don't get sms?

+6
source share
1 answer

Twilio evangelist developer is here.

Test account accounts do not actually send SMS messages; they are test endpoints that let you know that your HTTP calls are working properly. That is why you should use a specific number.

To verify the number purchased in your account, you will need to use your real account credentials. Your Twilio trial account does have a free credit to test these messages before you need to upgrade, so I recommend switching to using these real credentials and the number you bought, and you should start looking at the SMS messages coming in to your phone.

As a side note, calling client.sms.messages.create actually uses the deprecated API. You can upgrade this to client.messages.create and it will use the more modern Message client.messages.create . (Lateral point on this, although test credentials will not work at all with this endpoint, I still recommend using your real credentials and trial credit for testing.)

+3
source

All Articles