Quickstart#

Introduction#

Phone Object allows websites and custom applications to verify phone numbers down to 7 and 10 digits, update area codes, and append data about the phone number.

Sample Code#

Phone Object is compatible with multiple coding languages across different systems. The table below will link you to the sample code for each language hosted in the github repositories.

Language

System

Repository

C# .NET

Windows

melissa_favicon MelissaData/PhoneObject-Dotnet

Linux

melissa_favicon MelissaData/PhoneObject-Dotnet-Linux

melissa_favicon MelissaData/GeoObject-Dotnet-Wrappers

C++

Windows

melissa_favicon MelissaData/PhoneObject-Cpp

Linux

melissa_favicon MelissaData/PhoneObject-Cpp-Linux

Java

Windows

melissa_favicon MelissaData/PhoneObject-Java

Linux

melissa_favicon MelissaData/PhoneObject-Java-Linux

melissa_favicon MelissaData/GeoObject-Java-Wrappers

Python3

Windows

melissa_favicon MelissaData/PhoneObject-Python3

Linux

melissa_favicon MelissaData/PhoneObject-Python3-Linux

melissa_favicon MelissaData/GeoObject-Python3-Wrappers

How To Get Data#

Use the Melissa Updater to download the data files using the manifest named dq_phone_data.

Getting Started#

Basic Flow of Actions#

To use the Phone Object, you can give it a license, data path, and phone number. It will then analyze the phone number and store relevant information about it. It can also return result codes based on the validity of the phone number.

This is the flow of how Phone Object is usually implemented:

The Reference Guide goes into detail on every method available with the Phone Object. All the Result Codes and descriptions are also in the reference guide.

1. Initialize Phone Object#

Start by creating an instance of the Melissa Phone Object.

Example Implementation:

  • C#
  • C++
  • Java
  • Python3
// Create instance of Melissa Phone Object
public mdPhone mdPhoneObj = new mdPhone();
// Create instance of Melissa Phone Object
mdPhone* mdPhoneObj = new mdPhone;
// Create instance of Melissa Phone Object
mdPhone mdPhoneObj = new mdPhone();
# Create instance of Melissa Phone Object
md_phone_obj = mdPhone_pythoncode.mdPhone()

2. Set a License#

To set a license, either configure the environmental variable for the license or use the method SetLicenseString.

Example Implementation:

  • C#
  • C++
  • Java
  • Python3
// Set license string
mdPhoneObj.SetLicenseString(MELISSA_LICENSE_STRING);
// Set license string
mdPhoneObj->SetLicenseString(MELISSA_LICENSE_STRING.c_str());
// Set license string
mdPhoneObj.SetLicenseString(MELISSA_LICENSE_STRING);
# Set license string
md_phone_obj.SetLicenseString(MELISSA_LICENSE_STRING)

To see when the license will expire, use the method GetLicenseExpirationDate.

Example Implementation:

  • C#
  • C++
  • Java
  • Python3
Console.WriteLine($"Expiration Date: {mdPhoneObj.GetLicenseExpirationDate()}");
cout << "Expiration Date: " + string(mdPhoneObj->GetLicenseExpirationDate()) << endl;
System.out.println("Expiration Date: " + mdPhoneObj.GetLicenseExpirationDate());
print(f"Expiration Date: {md_phone_obj.GetLicenseExpirationDate()}")

3. Initialize Data Files#

To setup the data files, use the method Initialize with the data path as the parameter.

ProgramStatus can be used to store the result from InitializeDataFiles to ensure it worked as expected.

Example Implementation:

  • C#
  • C++
  • Java
  • Python3
// Set path to data files (.dat, etc)
mdPhone.ProgramStatus pStatus = mdPhoneObj.Initialize(PATH_TO_DATA_FILES);

if (pStatus != mdPhone.ProgramStatus.ErrorNone)
{
    Console.WriteLine("Failed to Initialize Object.");
    Console.WriteLine(pStatus);
    return;
}
// Set path to datafiles (.dat, etc)
mdPhone::ProgramStatus pStatus = mdPhoneObj->Initialize(PATH_TO_DATA_FILES.c_str());

if (pStatus != mdPhone::ProgramStatus::ErrorNone)
{
    cout << "Failed to Initialize Object." << endl;
    cout << pStatus << endl;
    return;
}
// Set path to data files (.dat, etc)
mdPhone.ProgramStatus pStatus = mdPhoneObj.Initialize(PATH_TO_DATA_FILES);

if (pStatus != mdPhone.ProgramStatus.ErrorNone) {
    // Problem during initialization
    System.out.println("Failed to Initialize Object.");
    System.out.println(pStatus);
    return;
}
""" Set path to data files  (.dat, etc) """
p_status = md_phone_obj.Initialize(PATH_TO_DATA_FILES)

if (p_status != mdPhone_pythoncode.ProgramStatus.ErrorNone):
    print("Failed to Initialize Object.")
    print(p_status)
    return

To check at what date the database was updated, use the method GetDatabaseDate.

The method GetBuildNumber gives the development build number of Phone Object.

Example Implementation:

  • C#
  • C++
  • Java
  • Python3
// If you see a different date than expected, check your license string and either download
// the new data files or use the Melissa Updater program to update your data files.
Console.WriteLine($"DataBase Date: {mdPhoneObj.GetDatabaseDate()}");

// This number should match with file properties of the Melissa Object binary file.
// If TEST appears with the build number, there may be a license key issue.
Console.WriteLine($"Object Version: {mdPhoneObj.GetBuildNumber()}\n");
// If you see a different date than expected, check your license string and either
// download the new data files or use the Melissa Updater program to update your data files.
cout << "DataBase Date: " + string(mdPhoneObj->GetDatabaseDate()) << endl;

// This number should match with the file properties of the Melissa Object binary file.
// If TEST appears with the build number, there may be a license key issue.
cout << "Object Version: " + string(mdPhoneObj->GetBuildNumber()) << endl;
// If you see a different date than expected, check your license string and either
// download the new data files or use the Melissa Updater program to update your data files.
System.out.println("DataBase Date: " + mdPhoneObj.GetDatabaseDate());

// This number should match with the file properties of the Melissa Object binary file.
// If TEST appears with the build number, there may be a license key issue.
System.out.println("Object Version: " + mdPhoneObj.GetBuildNumber());
# If you see a different date than expected, check your license string and either download
# the new data files or use the Melissa Updater program to update your data files.
print(f"DataBase Date: {md_phone_obj.GetDatabaseDate()}")

# This number should match with file properties of the Melissa Object binary file.
# If TEST appears with the build number, there may be a license key issue.
print(f"Object Version: {md_phone_obj.GetBuildNumber()}\n")

The method GetInitializeErrorString can get the status on errors in initialization. This can help determine if the code should continue running.

Example Implementation:

  • C#
  • C++
  • Java
  • Python3
bool shouldContinueRunning = true;

if (phoneObject.mdPhoneObj.GetInitializeErrorString() != "No error")
{
    shouldContinueRunning = false;
}
bool shouldContinueRunning = true;

if (string(mdPhoneObj->GetInitializeErrorString()) != "No error.")
{
    shouldContinueRunning = false;
}
bool shouldContinueRunning = true;

if (!phoneObject.mdPhoneObj.GetInitializeErrorString().equals("No error"))
  shouldContinueRunning = false;
should_continue_running = True

if phone_object.md_phone_obj.GetInitializeErrorString() != "No error":
    should_continue_running = False

4. Lookup and Verify the Phone Number#

Use the method Lookup to check the given phone number.

Example Implementation:

  • C#
  • C++
  • Java
  • Python3
// This will call the lookup function to process the input phone
// as well as generate the result codes
mdPhoneObj.Lookup(PHONE_NUMBER_STRING, ZIP_CODE_STRING);
// This will call the lookup function to process the input phone
// as well as generate the result codes
mdPhoneObj->Lookup(PHONE_NUMBER_STRING, ZIP_CODE_STRING);
// This will call the lookup function to process the input phone
// as well as generate the result codes
mdPhoneObj.Lookup(PHONE_NUMBER_STRING, ZIP_CODE_STRING);
# This will call the lookup function to process the input phone
# as well as generate the result codes
md_phone_obj.Lookup(PHONE_NUMBER_STRING, ZIP_CODE_STRING)

5. Get Phone Object Information#

These methods get data from the parsed phone number:

Example Implementation:

  • C#
  • C++
  • Java
  • Python3
mdPhoneObj.GetAreaCode();
mdPhoneObj.GetPrefix();
mdPhoneObj.GetSuffix();
mdPhoneObj.GetCity();
mdPhoneObj.GetState();
mdPhoneObj.GetLatitude();
mdPhoneObj.GetLongitude();
mdPhoneObj.GetTimeZone();
mdPhoneObj->GetAreaCode();
mdPhoneObj->GetPrefix();
mdPhoneObj->GetSuffix();
mdPhoneObj->GetCity();
mdPhoneObj->GetState();
mdPhoneObj->GetLatitude();
mdPhoneObj->GetLongitude();
mdPhoneObj->GetTimeZone();
mdPhoneObj.GetAreaCode();
mdPhoneObj.GetPrefix();
mdPhoneObj.GetSuffix();
mdPhoneObj.GetCity();
mdPhoneObj.GetState();
mdPhoneObj.GetLatitude();
mdPhoneObj.GetLongitude();
mdPhoneObj.GetTimeZone();
md_phone_obj.GetAreaCode()
md_phone_obj.GetPrefix()
md_phone_obj.GetSuffix()
md_phone_obj.GetCity()
md_phone_obj.GetState()
md_phone_obj.GetLatitude()
md_phone_obj.GetLongitude()
md_phone_obj.GetTimeZone()

6. Get the Melissa Result Codes#

To get the result codes, use the method GetResults. This will return all of the result codes stacked together in a single String separated by ‘,’ delimiters.

Example Implementation:

  • C#
  • C++
  • Java
  • Python3
String ResultCodes = mdPhoneObj.GetResults();

// ResultsCodes explain any issues Phone Object has with the object.
string ResultCodes = mdPhoneObj->GetResults();

// ResultsCodes explain any issues Phone Object has with the object.
String ResultCodes = mdPhoneObj.GetResults();

// ResultsCodes explain any issues Phone Object has with the object.
result_codes = md_phone_obj.GetResults()

# ResultsCodes explain any issues Phone Object has with the object.

The following implementation shows one way of interpreting the results by using the method GetResultCodeDescription:

  • C#
  • C++
  • Java
  • Python3
mdPhoneObj.GetResultCodeDescription(RESULT_CODE_STRING, mdPhone.ResultCdDescOpt.ResultCodeDescriptionLong);
mdPhoneObj->GetResultCodeDescription(RESULT_CODE_STRING.c_str(), phoneObject->mdPhoneObj->ResultCodeDescriptionLong);
mdPhoneObj.GetResultCodeDescription(RESULT_CODE_STRING, mdPhone.ResultCdDescOpt.ResultCodeDescriptionLong);
md_phone_obj.GetResultCodeDescription(RESULT_CODE_STRING, mdPhone_pythoncode.ResultCdDescOpt.ResultCodeDescriptionLong)