Question

My application sends SMS messages to people, but the numbers entered in as their cell phone are sometimes land lines (this is user error or the user not really knowing if the contact number they have is a cell phone or landline.)

I found a few websites that can tell me if a number is a landline or cell phone, but they do not offer programatic API's. Is anyone aware of a way a web application can figure out if a number can receive SMS messages?

I guess a test SMS message is one way, but my current SMS gateway fails hard when it gets a landline number and doesn't tell me the landline number it tried to send the SMS to. I'll follow this up with my carrier, but I would love an easy way to let the user entering phone numbers in if they are a landline or cell number.

Update: There are ways to figure this out. Take a look at http://www.phonevalidator.com, they can query a phone number and figure out if it is a landline or cell phone.

Was it helpful?

Solution

You can have JavaScript open a popup with the url: "http://www.phonevalidator.com/results.aspx?p=" + phoneNumber

OTHER TIPS

I am afraid the only real way to find it out is contact SMS gateway service providers. A list of them can be found here for example:

http://en.wikipedia.org/wiki/SMS_gateways

Anyway, instead of that I suggest doing the following:

When user inserts cell phone number into his or her profile, send testing SMS to this number with confirmation code. If number is not verified by user, don't bother sending SMS messages to it later on.

Actually there are land line operators that allow receiving SMS. Either by text2voice gateway or phone terminal with extended capability. Moreover, in Europe cell phone operators have started offering "virtual land lines", which are in fact GSM cell phones assigned to one particular base station. But they do follow land line numbering scheme.

Resuming — not allowing sending SMS to land line number is wrong.

It's not a free service, but a company called Targus (not the bag company) has an API for querying phone information. They can tell if it's landline or cell, even address validation. The charge based on how many queries you do (a few cents a query). http://www.targusinfo.com/

Followup: I contacted TARGUSinfo on Feb. 24, 2011 and was told by their sales rep that they only work with record sets in the hundreds-of-thousands to millions and generally their customers are plugged into their API for real-time access. Differentiating between cell numbers and land line numbers for smaller record sets is "not something they can assist with."

The following script returns

646-826-3879    LANDLINE

for the Stack Overflow hot line.

#!/usr/bin/perl -w
use strict;
use warnings;

use LWP::Simple;
use LWP::Simple::Cookies ( autosave => 1, file => "$ENV{'HOME'}/lwp_cookies.dat" );

my $usage = "Usage: $0 <phone_number>\n\nwhere phone_number is on format XXX-XXX-XXXX or XXXXXXXXX";

die $usage unless scalar @ARGV == 1;

my $number = shift @ARGV;
die $usage unless $number =~ /(\d\d\d)-?(\d\d\d)/;
my $NPA = $1;
my $NXX = $2;

#GET /search.asp?frmNPA=646&frmNXX=826&frmCity=&frmState=&frmZip=&frmCounty=&frmCompany=&search.x=0&search.y=0 HTTP/1.0
my $doc = get 'http://www.area-codes.com/search.asp?frmNPA=' . $NPA . '&frmNXX=' . $NXX . '&frmCity=&frmState=&frmZip=&frmCounty=&frmCompany=&search.x=0&search.y=0';

# html format:
#...
#    <td><strong>NXX Use Type:</strong></td>
#        <td>LANDLINE</td>
#...
my $next = 0;
my $result = "";
grep {
    if (/NXX Use Type:/) {
        $next = 1;
    } else {
        if ($next) {
            $next = 0;
            $result = $_;
        }
    }
} split(/\n/, $doc);

$result =~ /<[^>]*>(.*)<[^>]*>/;

print "$number\t$1\n";

I'm not sure if you want to do that really... If you want to tell if a number is reserved by a callphone or landline provider, you should be able to find the ranges in some documents from your country's telco supervising entity (not sure who does that in US - it might be http://www.nanpa.com/). Those documents are usually public.

But the problem is that mobile number != able to receive sms. With number porting and all the "unified communication" ideas nowadays you can easily have local numbers redirecting to mobiles, non-geographical numbers handling smses and local "special" numbers rewriting your incoming smses as facebook messages ;) For example my local "landline" number is redirected to a mobile in another country and couple of other locations.

You shouldn't be charged for a message sent to a nonexisting / otherwise strange number, so it might be a good way to check if someone can receive them. If you have a good control over the SMS gateway, you can send a message with delivery report active and expiry == immediate message (forgot the official name). Just send a test / welcome message - if it's not accepted, you can mark the number as unavailable. Otherwise, you can just ask for a "number that accepts SMSes" instead of a "cellphone number".

Trying to combine some answers here...

Daniel mentioned that

You can have JavaScript open a popup with the url: "http://www.phonevalidator.com/results.aspx?p=" + phoneNumber

Does this still work? I can't seem to reproduce it. If we can get that to work, then maybe we can use a script like the following...

#!/usr/bin/perl -w
use strict;
use warnings;

use LWP::Simple;

my $usage = "Usage: $0 <phone_number>\n\nwhere phone_number is on format XXX-XXX-XXXX or XXXXXXXXX";

die $usage unless scalar @ARGV == 1;

my $number = shift @ARGV;
die $usage unless $number =~ /(\d\d\d)-?(\d\d\d)/;
my $NPA = $1;
my $NXX = $2;

#GET /search.asp?frmNPA=646&frmNXX=826&frmCity=&frmState=&frmZip=&frmCounty=&frmCompany=&search.x=0&search.y=0 HTTP/1.0
my $doc = get 'http://www.phonevalidator.com/results.aspx?p=' . $NPA . $NXX;

# html format:
#...
#                                                       <td class="style16">
#                                Phone Line Type:
#                            </td>
#                            <td class="style13">
#                                <span id="PhoneTypeLabel">LANDLINE</span>
#                            </td>
#
#...
my $result = "";
grep {
    if (/PhoneTypeLabel/) {
        $result = $_;
    }
} split(/\n/, $doc);

$result =~ /<[^>]*>(.*)<[^>]*>/;

print "$number\t$1\n";

Another option would be to have the user select their cellphone provider from a list. Just a thought.

Why not make a list of the usual format for the landlines and mobile numbers? For example, where I'm located landlines always follow this format:

9xxxx xxxx

and mobiles are always:

04xx xxx xxx

You can easily make a list of the general format of landline/mobile numbers in the area you are serving. Then, when wanting to find out if a US number is landline or mobile, just compare it and see whether it matches the landline format or the mobile number format.

Another thing that is done often to validate phone numbers, is to send a temporary pin via SMS to the user's mobile, and ask them to enter that pin in order to validate their number.

I can imagine doing this, if I had access to the core mobile network. That's an SS7 API, though, not a Web API. I would bet that any service which offers a Web API acts as a proxy to the SS7 network, instead of relying on databases. The only other alternative would be to query the number porability database. Eventually, to terminate a call, all network operators need to determine which other operator they need to connect to.

we have a service which provides fixed line / cellular detection for USA and Canada, and also detects if the number is Live or Dead, which wireless carrier the number is ported to etc. There's a full web API.

If you sign up for an account at www.hlrcheck.com I'll get it validated and add some free credits for you to test. We're in beta at the moment, but full release candidate is imminent.

All solutions mentioned here are static number pattern lookups but the only reliable way to figure out whether a given cell phone number is valid (and ready to receive SMS) is to perform an HLR Lookup. HLR stands for Home Location Register, which is a mobile network operator database with real time subscriber information. There are several API services for HLR lookups, e.g. www.hlr-lookups.com.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top