Download the PHP package trafik8787/sms-verification-laravel without Composer
On this page you can find all versions of the php package trafik8787/sms-verification-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download trafik8787/sms-verification-laravel
More information about trafik8787/sms-verification-laravel
Files in trafik8787/sms-verification-laravel
Package sms-verification-laravel
Short Description Provides endpoints for sending SMS to some phone number and it's verifying.
License MIT
Informations about the package sms-verification-laravel
This library contains a set of two simple server endpoints for doing phone number verification via SMS.
SMS is done via phone.com API and in fact this code is intended to demonstrate real world use-case for using the phone.com API. All available Phone.com API's are defined at https://apidocs.phone.com.
Server is written in PHP using the Laravel framework.
Installation
Once this library is installed you need to register the service provider. Open config/app.php
and find the providers
key.
Run the command:
Add SMS Verification endpoints to your routing file:
The process for SMS verification is as follow:
- Use the POST
/sms-verification
to send the code to a mobile device - Use the GET
/sms-verification/{code}/{mobilePhoneNumber}
to verify the code
For example, if an app wants to send an authorization code to a cell phone 855-123-8765
- Send a POST
/sms-verification
API to URL https://api.example.com/sms-verification with JSON body{"phone_number" : "+18551238765"}
- The API returns
{"success":true,"description":"OK","expires_at": 1495120612}
if the code is sent.expires_at
is actual time of code expiration. - The cell phone will receive a 6-digit code (for example: 782025)
- In order to verify the code, send a Get /sms-verification API to
https://api.example.com/sms-verification/782025/+18551238765
- The API returns:
- On success:
{"success":true,"description":"OK","expires_at": 1495120612}
- On failure:
{"success":false,"description":"Wrong code"}
- On success:
Errors
If an exception was thrown during the SMS verification process, output contains field error
.
1XX
- code validation error2XX
- something is not configured3XX
- input format validation was failed5XX
- code generating error4XX
- code sending error999
- any other server error, not related to SMS Verification library
Notes
- The authorization code sent is only valid for 10 minutes
- The code can be verified only once. After the first success, it will be invalidated