Closed KingTut121 closed 3 years ago
Please try the following changes to the sms.py
file:
At the top after the other import statements:
import TwilioRestException from twilio.base.exceptions
Then change this code on line 50:
# Send the sms text to the number from the CSV file:
print("Sending to " + num)
message = client.messages.create(to=num, from_=from_num, body=sms)
to this:
# Send the sms text to the number from the CSV file:
print("Sending to " + num)
try:
message = client.messages.create(to=num, from_=from_num, body=sms)
except TwilioRestException as e:
print('Failed to send message to {}'.format(num))
print(e)
continue
Let me know if it works.
My bad if this is just an simple fix it’s just that I’m new to python lol. I’ve ran into an invalid syntax error here. What should be done?
On Tue, Feb 23, 2021 at 9:02 AM Samantha Finnigan notifications@github.com wrote:
Please try the following changes to the sms.py file:
At the top:
import TwilioRestException from twilio.base.exceptions
Then change this code on line 50 http://sms.py#L50:
# Send the sms text to the number from the CSV file: print("Sending to " + num) message = client.messages.create(to=num, from_=from_num, body=sms)
to this:
# Send the sms text to the number from the CSV file: print("Sending to " + num) try: message = client.messages.create(to=num, from_=from_num, body=sms) except TwilioRestException as e: continue
Let me know if it works.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sjmf/bulk-sms/issues/4#issuecomment-784223660, or unsubscribe https://github.com/notifications/unsubscribe-auth/AS6WTHEYRZAMJUR4ASDGETTTAOYOLANCNFSM4YCQVXZA .
I'm trying to understand what the issue is, but I need more information. If there's a syntax error, please look at the error message and try and understand which part of the code it's hitting it on.
For me to be able to help, I need to see the traceback and the code which is throwing the error.
The 'traceback' is the error message, including all the lines which show where it occurs in the program– the bit you removed from the original post. ;)
At a complete guess, given that you're new to Python, have you mixed tabs and spaces in the file?
Code stops when it comes upon an invalid number
twilio.base.exceptions.TwilioRestException: HTTP 400 error: Unable to create record: The 'To' number + is not a valid phone number.