Python
You can easily send SMS and verify users with our helper library for Python
Setup
To be able to use TextFlow for sending an SMS or user verification, you first have to register an account, after that you are going to get a free API key with two free SMS, which you can use to send SMS or verify user request anywhere in the world.
After you have registered an account, your API key will be available on the API console.
After you have your API key, you need to install the textflowsms
PyPi package:
Next thing you have to do is just to load the library and supply your API key.
Sending an SMS
Once you have initialized the library, you can easily send a simple SMS by using the sendSMS
function.
You can also handle the result of the function, which contains the information if the message was successfully sent.
result
is a Python object, with the following structure:
User verification
There are two functions that you should call on your back-end during the user verification process, but firstly you should make sure that you have set up everything correctly.
sendVerificationSMS
is used to send user the verification code, while the verifyCode
is used to check if the code that the user has entered is valid.
When you call the sendVerificationSMS
function, we will send an SMS to the specified phone number. It should be the phone number that you want to verify, e.g. the phone number the user has entered in your app.
After sending the verification SMS, you can show the user a form where he should enter the verification code that he should have got in the SMS. When he submits the code, you should call the verifyCode
function and supply his phone number (which he can send again when submitting the code) along with the code that you want verified.
That way, you do not have to worry about keeping data about phone verification in your database, because we are doing it for you.
Here is the pseudocode for the whole process:
service_name
is what the user will see in the verification message, e. g. "Your verification code for Guest is: CODE"
seconds
is how many seconds the code is valid. Default is 10 minutes. Maximum is one day.
Here are the example result objects of the sendVerificationSMS
function:
And here are the example result objects of the verifyCode
function:
Getting help
If you need help installing or using the library, please check the FAQ first, and contact us at [email protected] if you don't find an answer to your question.
If you've found a bug in the API, package or would like new features added, you are also free to contact us!
Last updated