Account  |   Register  |   Pricing  |   Asterisk  |   HTTP API   |   Code  |   Batch Client   |   Coverage  |   Status  |   About  |   Contact

Number Portability Lookup - Sample Code for Carrier Query: PHP

PHP Sample Code:

This example code shows how to query the mobile network carrier of a subscriber using the PHP language and the NumberPortabilityLookup service. The code could be integrated into a website using PHP, or any other PHP script where you need carrier lookup functionality.

Other Code Samples & Asterisk Carrier Lookup Examples

To find code samples for other languages, or number portability lookup integration examples for the Asterisk PBX, click here.

Code Sample:


# Sample Number Portability Lookup carrier query in PHP

# Customise these for your own username/password
# Free test account available at

$user= "your-username";
$pass= "your-password";

# Number to query:


# Call the API and read the response:

$response = file_get_contents($url);

$data = split("\n",$response);

if ($data[0]=="QUERYOK")
	list($msisdn,$carrier)=split(" ",$data[1]);
	echo "Carrier for $msisdn is $carrier";
	echo "Query failed";
?>™ & © 2023 SES IP Holdings Ltd - All Rights Reserved. Service operated by Wizard Island Software LLC.