Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Validating Global Phone Numbers 101: A Quick, Easy Tutorial

DZone's Guide to

Validating Global Phone Numbers 101: A Quick, Easy Tutorial

This quick, simple guide will show you how to use Melissa Data's Global Phone Object for simple phone number validation across the world.

· Java Zone ·
Free Resource

Verify, standardize, and correct the Big 4 + more– name, email, phone and global addresses – try our Data Quality APIs now at Melissa Developer Portal!

With the advent of global communications and business, chances are you are not only capturing addresses of your contacts, but contact phone numbers as well. This is where Melissa's Global Phone Object comes into play.

Global Phone Object validates registered phone numbers in more than 240 countries and territories, as well as enrich your data by appending information such as latitude, longitude, city, predominant language spoken, and more.

Setting up the object is quick and easy, especially if you're a current customer of any other Melissa API.

Here's a quick tutorial.

First, add the Phone Object DLL or .SL file to your project and instantiate an instance of the Global Phone Object:

SET globalPhonePtr as NEW Instance of GlobalPhone


Second, set your license string:

CALL SetLicenseString WITH LicenseString


Next, initialize the data files:

CALL Initialize WITH DataPath RETURNING Result
IF Result <> 0 THEN
     CALL GetInitializeErrorString RETURNING
ErrorString
    PRING "Error: " & ErrorString
ENDIF


Now you're ready to start validating phone numbers! Using the 'Lookup' method, you can now loop through and feed your contact phone numbers through the object. For best results, pass in both the phone number and country associated with it with the Lookup method. If you require all the digits necessary for dialing internationally from your country, you will also need to pass in the Country of Origin (e.g. the country from which the caller is dialing from).

The outputs returned from the Global Phone Object are useful for call-centers or businesses that would benefit from knowing about the general area the contact is located. For instance, the UTC (Universal Time Code) output can help the caller schedule an appropriate time to dial the contact and the language output can provide the caller information on the language most comfortable for the contact.

The appended regional information, such as the latitude, longitude, locality (city), and administrative area (state) can be sued to get a general sense of where the majority of your contacts are located.

If you're capturing international contact information, the Global Phone Object will be a useful tool in determining registered phone numbers, standardizing phone number formats, and understanding more about where the contact is located.

Image title

Click here to test Global Phone for free.

Developers! Quickly and easily gain access to the tools and information you need! Explore, test and combine our data quality APIs at Melissa Developer Portal – home to tools that save time and boost revenue. Our APIs verify, standardize, and correct the Big 4 + more – name, email, phone and global addresses – to ensure accurate delivery, prevent blacklisting and identify risks in real-time.

Topics:
java ,validation ,phone number ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}