Reputation: 2931
We have a database of contacts and their phone numbers, and we would like to validate whether these phone numbers actually exists. I googled and did not find any solution. I am looking for one of the following, though I prefer the first option.
Write code using existing phone library to check whether the phone of the contact actually exists. Probably we make the phone ring once or twice
Use an existing software that can be used to ring the phone and validate user contact number manually.
Any help is greatly appreciated.
Upvotes: 3
Views: 4792
Reputation: 3228
I've been working on an application that sends text messages to phone numbers. What I found is that text messages are actually handled from STMP. When you send a text message, it's being sent to
For example
[email protected]
would refer to Verizon's number.
Hypothetically, then, you can check if a number exists by querying every service provider and checking for a response. Not sure if this will work with landlines.
You can find a list of service providers here
I would iterate through each of the providers on the list and check if you can extract a response. If you can't, time to change gears- a phone directory will contain landline numbers. We've eliminated every number on the American grid except any cell phone without texting, which is becoming increasingly rare.
Update: This technique is effective, but it can be illegal in some states if abused, and you may incur messaging charges. This should only be used to check a few select numbers, rather than attempting to profile users who haven't given consent for their info to be used.
Upvotes: 6
Reputation: 1682
Maybe you could use Asterisk and use a connector to MySQL.
This is not really an answer but just an idea.
Maybe you can ask the community on their forum
Upvotes: 1
Reputation: 188
you can check
//10-digit phone number ^(?:+?1\s*(?:[.-]\s*)?)?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$
//10-digit phone number, extension allowed ^(?:+?1\s*(?:[.-]\s*)?)?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x.?|ext.?|extension)\s*(\d+))?$
//7 or 10-digit phone number ^(?:(?:+?1\s*(?:[.-]\s*)?)?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$
//7 or 10-digit phone number, extension allowed ^(?:(?:+?1\s*(?:[.-]\s*)?)?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x.?|ext.?|extension)\s*(\d+))?$
//10-digit phone number, vanity (alphanumeric) allowed ^(?:+?1\s*(?:[.-]\s*)?)?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?([2-9a-z]1[02-9a-z]|[2-9a-z][02-9a-z]1|[2-9a-z][02-9a-z]{2})([0-9a-z]{4})$
//10-digit phone number, vanity allowed, extra characters allowed at end ^(?:+?1\s*(?:[.-]\s*)?)?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?([2-9a-z]1[02-9a-z]|[2-9a-z][02-9a-z]1|[2-9a-z][02-9a-z]{2})([0-9a-z]{4})([0-9a-z]*)$
also, i have found the regex that check the USA numbers.
^([0-9]{3})[0-9]{3}-[0-9]{4}$ and
^[0-9]{3}-[0-9]{3}-[0-9]{4}$ is to use alternation ((...|...)): specify them as two mostly-separate options:
^(([0-9]{3})|[0-9]{3}-)[0-9]{3}-[0-9]{4}$ By the way, when Americans put the area code in parentheses, we actually put a space after that; for example, I'd write (123) 123-1234, not (123)123-1234. So you might want to write:
^(([0-9]{3}) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$
i hope it will work for all formats listed in wiki
http://en.wikipedia.org/wiki/Category:Telephone_numbers_in_the_United_States
Upvotes: 1
Reputation: 1246
Your question involves a lot of blurring about your requirements. However let's get some general ideas.
Any repository on natural facts ages instantly as long as there is no proper update process installed. This is a sort of fundamental truth and you can derive some conclusions from there if you keep in mind that there is no intrinsic process that keeps people from updating their number as they change:
a. any repository including these of existing software will have outdated data b. the second you are done with your phone number validation these data will age
You can derive following conclusions out of these conclusions depending on your requirements:
For randomly generating US phone numbers I would start from there:
http://en.wikipedia.org/wiki/North_American_Numbering_Plan
Upvotes: 2