This example shows how Plivo APIs can be used to integrate a two factor authentication system into your own web application. This example is built in PHP.
In other languages:
Node.js | Done |
Python | Done |
Ruby | Done |
.NET | Done |
This application verifies your phone number using the two factor authentication system.
-
Clone this repo.
git clone git@github.com:plivo/2fa-php-demo.git
-
Change your working directory to 2fa-php-demo
cd 2fa-php-demo
-
Install the dependencies using the composer.json file. You can use the below command.
composer install
-
Change the placeholders in the
config.ini
file. You should replace the PLIVO_AUTH_ID, PLIVO_AUTH_TOKEN, & PLIVO_NUMBER placeholders. Note: If you do not want to use PHLO, then set the value toPHLO_ID = null
-
You can get your auth_id & auth_token from your Plivo Console. Please sign up for a Plivo account if you do not have one already.
Note: Enter your phone number in E.164 format.
-
Use the below command to start the app.
php -S localhost:8000
- Enter your phone number and click on
Send Verification Code
. - This sends an SMS to that number with a random security code in it. The application now shows a text box to enter this code to verify your mobile number.
- Once you get the code in the SMS, enter the code in the text box and click
Verify
. This will tell you whether the code you entered is correct or not. - If you enter the correct code, then the application knows that the phone number belongs to you and thus the number is verified.
Helper libraries for various languages are available on the Plivo github page.