views:

2088

answers:

10

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.

+4  A: 

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.

Koistya Navin
That doesn't seem right. I gave an example of a site that figures out if the # is a landline or cell. In my case the numbers are for 3rd parties so I can't contact the person who actually owns the phone number without a good reason.
MikeN
You should also know that such service can not be 100% accurate, especially if you work with international phone numbers.
Koistya Navin
Actually, instead of sending THEM an SMS, ask them to send YOU an SMS that contains something, if you can receive them. That way, the cost is minimized for all parties.
Thomas Owens
+1  A: 

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";
hlovdal
This is a really interesting idea (to screenscrape one of the sites), but the area-codes.com site is wrong. It reports cell phones as landlines as well (even ones in the NY cell phone 917 area code.) I also don't know how scalable it is, they aren't offering an API. If they find my web server hitting their site hard in a programattic way they will blacklist me.
MikeN
+4  A: 
vartec
Thank you for raising an interesting point. My SMS product is targeted at the US market and I'd be happy to send SMS messages to any phone that would receive them. To my user's perspective I'm asking them to enter in a person's cell phone, primarily for SMS messages, but to the user they might also care if that cell number is carried around by the person to contact them when they are not home.
MikeN
A: 

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

Daniel A. White
+2  A: 

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".

viraptor
A: 

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.

Click Upvote
Unfortunately, in North America there is no separation of landline vs mobile numbers in this way. They all share the same numbering plan without any distinction. And, with number portability customers can switch from a landline to a mobile provider without changing their phone number at all.
Greg Hewgill
+4  A: 

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/

Brent Baisley
A: 

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.

MSalters
+1  A: 

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

Daniel
Daniel
A: 

I don't know if you still on it. Try this, they've API too http://www.searchbug.com/

Vishal Patel