PHP Classes

Free Phone Number Verification in PHP: Verify phone numbers of many countries

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog (1)    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 63%Total: 1,442 This week: 1All time: 2,713 This week: 560Up
Version License PHP version Categories
numverify 1.0GNU General Publi...5PHP 5, Web services, Validation
Description 

Author

This class can verify the phone numbers of many countries.

It can send HTTP requests to the numverify.com API Web server to request verification if a given number is valid.

The class returns whether or not the number was found to be valid, or sets error variables in case of verification failure.

Innovation Award
PHP Programming Innovation award nominee
December 2015
Number 2


Prize: One downloadable e-book of choice by O'Reilly
Nowadays many sites send SMS messages to communicate with the users or just validate that they own a given phone number. However sending SMS messages requires using a service that costs money.

This class can reduce the costs of sending SMS messages to numbers that the user informed incorrectly by making a basic verification using the numverify API.

Manuel Lemos
Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 58
All time rank: 618 in United States United States
Week rank: 21 Up4 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Example

<?php
/*
verify phone number
numverify ver 1.0
*/

//include the class
include('numverify.class.php');

//instantiate the class
$numVerify = new numVerify();

//phone number to check
//API can accept all numeric numbers or number with special characters like (555) 5555-55555
$phoneNumber = 'ADD_A_PHONE_NUMBER_HERE';

//logic to determine if number is valid, invalid or an error occured
if( $numVerify->isValid($phoneNumber,'US',false,true) === false ){

    if( !empty(
$numVerify->errorCode) ){
       
//an error occured

       
echo 'The request returned an error -> ['.$numVerify->errorCode.'] '.$numVerify->errorText;

    }else{
       
//number is not valid

       
echo 'The phone number '.$phoneNumber.' is NOT valid';

    }

}else{
   
//number is valid

   
echo 'The phone number '.$phoneNumber.' is valid';

}

//display the response object
echo '<hr>';
echo
'<pre>';
var_dump($numVerify->response);
echo
'</pre>';

/*
a validation request will return the following object properties

valid - true or false
number - clean format of phone number provided
local_format - local/national format of phone number
international_format - international format of phone number with calling code
country_code - 2-letter country code
country_name - full country name
location - local location if available (country, state, etc)
carrier - name of phones carrier, service provider
line_type - line type
    mobile = mobile phone
    landline = land line
    special_services = police, fire, etc...
    toll_free = toll free number
    premium_rate = paid services number like hotlines

*/
?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example Usage
Accessible without login Plain text file license.txt Lic. License
Plain text file numverify.class.php Class Main Class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,442
This week:1
All time:2,713
This week:560Up
User Ratings User Comments (1)
 All time
Utility:93%StarStarStarStarStar
Consistency:81%StarStarStarStarStar
Documentation:-
Examples:87%StarStarStarStarStar
Tests:-
Videos:-
Overall:63%StarStarStarStar
Rank:784