Phone-Number-Verification is a project mainly written in PHP, it's free.
Tool to verify a users phone number with PHP and Twilio
This tool allows you to verify a users telephone number by presenting them with a 4 digit number on the screen, and then phoning them on the number they provided, asking them to confirm the digits on the screen. The tool uses Twilio to make the call and process the users interaction.
Download and extract the twilio PHP library into the libraries/twilio folder. https://github.com/twilio/twilio-php.
A UserAdapter class is included which includes required methods and skeleton functionality for this tool to work with user objects within your own framework. You should update the logic in this file to make it compatible with your own user objects, and pass user objects to it. This provides a common/standard interface for the tool to access.
require_once( 'PhoneVerification.class.php' );
require_once( 'UserAdapter.class.php' );
// You should update the adapter code to work with your framework/application
$user = new UserAdapter( $myApplicationsUserObject );
// where the URL is the URL to the script which processes the call
$phoneVerification = new PhoneVerification( 'http://yourdomain/usage_processcall.php', $user, 'TwilioSID', 'TwilioToken' );
// pass 4 digit code, Caller ID (twilio app phone number), users country code, users phone number
$phoneVerification->callUser( '1234', '44111111111', '44', '12345678' );
require_once( 'PhoneVerification.class.php' );
require_once( 'UserAdapter.class.php' );
$user = new UserAdapter( $myApplicationsUserObject );
$phoneVerification = new PhoneVerification( 'http://yourdomain/usage_processcall.php', $user, 'TwilioSID', 'TwilioToken' );
$phoneVerification->handleCall();
exit();
Depending on your framework/application, the recommended approach would be: