Find People at an Address
Web service to obtain the names and telephone numbers of all residents at a specific address by entering a postcode and premises (house name or number).
By combining the functionality of our telephone and address lookup services with the Electoral Roll search, we have created a powerful people finding tool. We can offer much broader coverage of the UK than any other facility as this service not only searches the Electoral Roll data but also Directory Enquiries data.
Add this service to your website or business application and before you know it, your business has its own enhanced personal UK phonebook!
The Find People at an Address service costs from 6p per use. Please contact us if you have any questions.
<?php
// Get postcode and premises from query string or set to empty
$postcode = isset($_GET['postcode']) ? $_GET['postcode'] : '';
$premises = isset($_GET['premises']) ? $_GET['premises'] : '';
$url = "http://t2a.co/rest?"
. "method=address_person"
. "&api_key=sw9edtx-UZE7gM1t-5yotvjDzRItqiUw7adP5gmq1w_c" // Replace this API key with your own
. "&postcode=" . urlencode($postcode)
. "&premises=" . urlencode($premises);
// Fetch XML from T2A API
$result = simplexml_load_file($url);
if($result) {
// Check for errors
if($result->status == 'ok') {
$person_list = $result->person_list;
} else {
// Report error
echo "Error: $result->error_code";
exit;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Code example</title>
</head>
<body>
<?php
// check for people
if($person_list->person):
?>
<table>
<tr>
<th>Title</th>
<th>Forename</th>
<th>Surname</th>
<th>Telephone number</th>
</tr>
<?php
// iterate over list of people
foreach($person_list->person as $person): ?>
<tr>
<td><?php echo $person->title; ?></td>
<td><?php echo $person->forename; ?></td>
<td><?php echo $person->surname; ?></td>
<td><?php echo $person->telephone_number; ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php else: ?>
<p>No people found at this address.</p>
<?php endif; ?>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Code example</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".demo").submit(function() {
$.getJSON(
"http://t2a.co/rest?callback=?",
{
'method':'address_person',
'api_key':'sw9edtx-UZE7gM1t-5yotvjDzRItqiUw7adP5gmq1w_c', // better to use js_key obtained from javascript_key service
'output':'json',
'postcode':$("#postcode").val(),
'premises':$("#premises").val()
},
function(result) {
$('#loading').remove();
if(result.status == "ok") { // No errors
var html = '<p><strong>The following people were found at the address:</strong></p>';
html += '<table><tr><th>Title</th><th>Forename</th><th>Surname</th><th>Telephone number</th></tr>';
$.each(result.person_list, function() {
html += '<tr><td>' + this.title + '</td>'
+ '<td>' + this.forename + '</td>'
+ '<td>' + this.surname + '</td>'
+ '<td>' + this.telephone_number + '</td>'
+ '</tr>';
});
$("#results").html(html);
} else {
var error_msg;
switch(result.error_code) {
case "invalid_address":
error_msg = "The address you entered does not exist. Please check and try again.";
break;
default:
error_msg = "Sorry, we couldn't find details about people living at that address.";
}
$("#results").html($("<p><strong>" + error_msg + "</strong></p>"));
}
}
);
return false;
});
});
</script>
</head>
<body>
<form class="demo">
<ul>
<li>
<label for="postcode">Postcode:</label>
<input type="text" id="postcode" />
</li>
<li>
<label for="premises">Premises:</label>
<input type="text" id="premises" />
</li>
<li>
<input type="submit" />
</li>
</ul>
</form>
<div id="results"></div>
</body>
</html>
<%@ language="vbscript" %>
<% Option Explicit %>
<%
Dim input_postcode
Dim input_premises
Dim api_key
Dim url
Dim status
Dim error_code
Dim title_array
Dim forename_array
Dim surname_array
Dim tel_array
input_postcode = Request.QueryString("postcode")// Get postcode from query string
input_premises = Request.QueryString("premises")// Get premises from query string
api_key = "sw9edtx-UZE7gM1t-5yotvjDzRItqiUw7adP5gmq1w_c"// Replace this API key with your own
// build the url
//
url = "http://t2a.co/rest?method=address_person&api_key=" & api_key
url = url & "&postcode=" & Server.urlencode(input_postcode)
url = url & "&premises=" & Server.urlencode(input_premises)
On Error Resume Next
Dim xmlDoc
Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlDoc.setProperty "ServerHTTPRequest", true
xmlDoc.async=false
if(xmlDoc.load(url)) Then
//xml has loaded
//read the status
status = xmlDoc.getElementsByTagName("status").item(0).text
if( status = "error") Then
//read the error code
error_code = xmlDoc.getElementsByTagName("error_code").item(0).text
Else
//read the <person> data
//read arrays of all the members of each <person>
Set title_array = xmlDoc.getElementsByTagName("person_list/person/title")
Set forename_array = xmlDoc.getElementsByTagName("person_list/person/forename")
Set surname_array = xmlDoc.getElementsByTagName("person_list/person/surname")
Set tel_array = xmlDoc.getElementsByTagName("person_list/person/telephone_number")
End If
Else
//xml failed to load, so set an error
status = "error"
error_code = "xml failed to load"
End If
Set xmlDoc = nothing
If Err.Number Then
Err.Clear
End If
if(status = "error") Then
Response.Write("Error: " & error_code)
Response.End
End if
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Code example</title>
</head>
<body>
<table>
<tr>
<th>Title</th>
<th>Forename</th>
<th>Surname</th>
<th>Telephone number</th>
</tr>
<%
Dim i
i=0
//create the markup here, using the arrays found above...
table = ""
While(i<surname_array.length)
Response.Write("<tr>")
Response.Write("<td>" & title_array.item(i).text & "</td>")
Response.Write("<td>" & forename_array.item(i).text & "</td>")
Response.Write("<td>" & surname_array.item(i).text & "</td>")
Response.Write("<td>" & tel_array.item(i).text & "</td>")
Response.Write("</tr>")
i = i+1
Wend
%>
</table>
</body>
</html>
<%@ page import="com.simunix.t2a.*" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<%
// You may download the t2a Java library (com.simunix.t2a) from http://t2a.co/downloads
//
//
String inputPostcode = request.getParameter("postcode");// get postcode from query string
String inputPremises = request.getParameter("premises");// get premises from query string
String apiKey = "sw9edtx-UZE7gM1t-5yotvjDzRItqiUw7adP5gmq1w_c";// replace this API key with your own
// create an instance of AddressPerson, using the apiKey
//
AddressPerson myClass = new AddressPerson(apiKey);
//execute the class instance, using the input values
myClass.execute(inputPostcode,inputPremises);
//
// check for errors
//
String res=myClass.isCompleted();
if(!res.equals("ok"))
{
//print the error code
out.println("Error: " + myClass.getErrorCode());
//..and exit
return;
}
// no errors, proceed to display the results...
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Code example</title>
</head>
<body>
<%
// check for people
if(myClass.getPersonData() != null)
{
%>
<table>
<tr>
<th>Title</th>
<th>Forename</th>
<th>Surname</th>
<th>Telephone number</th>
</tr>
<%
// iterate over list of people
for(int i=0;i<myClass.getPersonData().length;i++)
{
%>
<tr>
<td><% out.print(myClass.getPersonData()[i].getTitle());%></td>
<td><% out.print(myClass.getPersonData()[i].getForename());%></td>
<td><% out.print(myClass.getPersonData()[i].getSurname());%></td>
<td><% out.print(myClass.getPersonData()[i].getTelephoneNumber());%></td>
</tr>
<%
}//end of iteration
%>
</table>
<%
}
else
{
%>
<p>No people found at this address.</p>
<%
}
%>
</body>
</html>
