This API that has been made to be used as a web service. It is .Net based and can be used by any application regardless of programing language. The service has two functions, GetResultByName and GetResultByNumber, and the return type of these functions is array of string type.
1) the function GetResultByName has the following declaration.
GetResultByName(firstname,lastname,city,state) as string()
this function has four parameters, firstname, lastname, city and state. Parameter "lastname" is an essential parameter that must be given. This function returns the address and the phone number of the owner of given details.
2) the function GetResultByNumber has the following declaration.
GetResultByNumber(num) as string()
this function has only one parameter "num". This function returns the Name and the address of the owner of given number.
Example 1) GetResultByName(firstname,lastname,city,state) as string
First Name: Adam [optional]
Last Name: Smith [mandatory]
City: [optional]
State: [optional]
the result will be the detail of the owner including the address and the phone number of the owner.
Example 2) GetResultByNumber(num) as string()
Number: 7134672333
the result will be the detail of the owner including the address and the phone number of the owner.
PHP Example: GetResultByNumber(num) as string()
include "Const.inc.php";
include "$INCLUDEPATH/ADb.inc.php";
include("lib/nusoap.php");
$area=$_POST['Area'];
$tel1=$_POST['Tel1'];
$tel2=$_POST['Tel2'];
$num = $area . $tel1 . $tel2;
$myADb = new ADb();
$firstname=Null;
$lastname=Null;
$address=Null;
$city=Null;
$state=Null;
$zip=Null;
$phone=Null;
$strSQL = "SELECT * FROM ReverseInfo WHERE Phone='$num'";
$Result = $myADb->ExecuteQuery($strSQL);
if ($Result->fields[7] == $num)
{
while(!$Result->EOF)
{
echo $firstname = $Result->fields[1];
echo $lastname = $Result->fields[2];
echo $address = $Result->fields[3];
echo $city = $Result->fields[4];
echo $state = $Result->fields[5];
echo $zip = $Result->fields[6];
echo $phone = $Result->fields[7];
$Result->MoveNext();
}
}
else
{
$wsdlURL = "http://dev4.tvpakistan.com/SearchService.asmx?wsdl";
$soap = new soapclient($wsdlURL, "wsdl");
if ($_POST)
{
$parameters['parameters']['num'] = $num;
$result = $soap->call("GetResultByNumber", $parameters);
//print_r($result);
$lastname = $result['GetResultByNumberResult']['string'][0];
$firstname = $result['GetResultByNumberResult']['string'][1];
$address = $result['GetResultByNumberResult']['string'][3] . " " . $result['GetResultByNumberResult']['string'][4];
$city = $result['GetResultByNumberResult']['string'][4];
$name = $fname . $lname;
if ($error=$soap->getError())
{
die($error);
}
if (is_null($result))
{
echo "Record not found";
exit;
}
$insSQL = "INSERT INTO ReverseInfo(FirstName,LastName,Address,City,Phone)
VALUES('$firstname','$lastname','$address','$city','$num')";
$Result = $myADb->ExecuteQuery($insSQL);
exit;
}
}
?>
In the code example "GetResultByNumber(num)as string()" is used. The execution of the above code is simple, first the function is called and the corresponding record is fetched from the database, if the record is available in the database then it will simply be fetched and displayed. On the other hand, if the record is not available in the database, then it will use the web service, fetch the record if available, save it in the database and finally display it.
Demo