Note that a return value of false does not necessarily indicate that the person does not live at the address given. A person may
be opted-out of the edited electoral roll and may not appear on the other data sources used to supplement the electoral roll,
but may still be a resident at the address.
Language:
<!-- Import the Integr8 Ajax API -->
<!-- NOTE: Get your own API key to use in the following script tag from: -->
<!-- http://www.data-8.co.uk/integr8/Admin/Ajax.aspx -->
<script src="http://webservices.data-8.co.uk/Javascript/Loader.ashx?key=your-api-key" type="text/javascript">
</script>
<script type="text/javascript">
function loadIntegr8() {
// Load the Demographics Integr8 service
data8.load('Demographics');
}
function GetDemographics(postcode) {
/// <param name="postcode">string</param>
var demographics = new data8.demographics();
demographics.getdemographics(
postcode,
null,
showGetDemographicsResult
);
}
function showGetDemographicsResult(result) {
// Check that the call succeeded, and show the error message if there was a problem.
if (!result.Status.Success) {
alert('Error: ' + result.Status.ErrorMessage);
}
else {
// TODO: Process method results here.
// Results can be extracted from the following fields:
// result.SonarCode
// Contains the full Sonar code.
// result.Title
// Contains the title of the Sonar code.
// result.PercentageOfHouseholds
// Shows the percentage of the UK who fit into this Sonar code.
// result.Lifestage
// Contains the Lifestage from A (Young Singles) to F (Retired).
// result.WealthQuartile
// Contains the Affluence Quartile from 1 (Affluent) to 4 (Struggling).
// result.WealthRanking
// Contains the Wealth Ranking from 1 (Wealthiest) to 100 (Poorest)
// result.Description
// Contains a detailed textual description for the type of person that typically lives in this postcode
}
}
loadIntegr8();
</script>
// NOTE: A reference to the web service must be added in Visual Studio with the URL
// http://webservices.data-8.co.uk/Demographics.asmx
private void GetDemographics(string postcode)
{
// Invoke the web service method.
Demographics proxy = new Demographics();
DemographicsOutput results = proxy.GetDemographics("username", "password", postcode, null);
// Check that the call succeeded, and show the error message if there was a problem.
if ((results.Status.Success == false))
{
MessageBox.Show(("Error: " + results.Status.ErrorMessage));
}
else
{
// TODO: Process method results here.
// Results can be extracted from the following fields:
// result.SonarCode
// Contains the full Sonar code.
// result.Title
// Contains the title of the Sonar code.
// result.PercentageOfHouseholds
// Shows the percentage of the UK who fit into this Sonar code.
// result.Lifestage
// Contains the Lifestage from A (Young Singles) to F (Retired).
// result.WealthQuartile
// Contains the Affluence Quartile from 1 (Affluent) to 4 (Struggling).
// result.WealthRanking
// Contains the Wealth Ranking from 1 (Wealthiest) to 100 (Poorest)
// result.Description
// Contains a detailed textual description for the type of person that typically lives in this postcode
}
}
'NOTE: A reference to the web service must be added in Visual Studio with the URL
'http://webservices.data-8.co.uk/Demographics.asmx
Private Sub GetDemographics(ByVal postcode As String)
'Invoke the web service method.
Dim proxy As Demographics = New Demographics()
Dim results As DemographicsOutput = proxy.GetDemographics("username", "password", postcode, Nothing)
'Check that the call succeeded, and show the error message if there was a problem.
If (results.Status.Success Is false) Then
MessageBox.Show(("Error: " + results.Status.ErrorMessage))
Else
'TODO: Process method results here.
'Results can be extracted from the following fields:
'result.SonarCode
' Contains the full Sonar code.
'result.Title
' Contains the title of the Sonar code.
'result.PercentageOfHouseholds
' Shows the percentage of the UK who fit into this Sonar code.
'result.Lifestage
' Contains the Lifestage from A (Young Singles) to F (Retired).
'result.WealthQuartile
' Contains the Affluence Quartile from 1 (Affluent) to 4 (Struggling).
'result.WealthRanking
' Contains the Wealth Ranking from 1 (Wealthiest) to 100 (Poorest)
'result.Description
' Contains a detailed textual description for the type of person that typically lives in this postcode
End If
End Sub
Public Sub GetDemographics(postcode As String)
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "http://webservices.data-8.co.uk/recordset.ashx?service=Demographics&method=GetDemographicsSimple" &
"&username=your-username" &
"&password=your-password" &
"&postcode=" & postcode
If rs.MoveFirst Then
If rs.Fields(0).Name = "Success" And rs.Fields(0).Value = false Then
MsgBox "Error: " & rs.Fields(1)
Else
'TODO: Process method results here.
'All the results are available in the first row in the recordset.
'Results can be extracted from the following fields:
'SonarCode
' Contains the full Sonar code.
'Title
' Contains the title of the Sonar code.
'PercentageOfHouseholds
' Shows the percentage of the UK who fit into this Sonar code.
'Lifestage
' Contains the Lifestage from A (Young Singles) to F (Retired).
'WealthQuartile
' Contains the Affluence Quartile from 1 (Affluent) to 4 (Struggling).
'WealthRanking
' Contains the Wealth Ranking from 1 (Wealthiest) to 100 (Poorest)
'Description
' Contains a detailed textual description for the type of person that typically lives in this postcode
End If
End If
End Sub
// NOTE: The php_soap.dll extension must be enabled in the php.ini file.
function GetDemographics($postcode)
{
$params = array(
"username" => "your-username",
"password" => "your-password",
"postcode" => $postcode,
"options" => $options
);
$client = new SoapClient("http://webservices.data-8.co.uk/Demographics.asmx?WSDL");
$result = $client->GetDemographics($params);
if ($result->GetDemographicsResult->Status->Success == 0)
{
echo "Error: " . $result->GetDemographicsResult->Status->ErrorMessage;
}
else
{
// TODO: Process method results here.
// Results can be extracted from the following fields:
// $result->GetDemographicsResult->SonarCode
// Contains the full Sonar code.
// $result->GetDemographicsResult->Title
// Contains the title of the Sonar code.
// $result->GetDemographicsResult->PercentageOfHouseholds
// Shows the percentage of the UK who fit into this Sonar code.
// $result->GetDemographicsResult->Lifestage
// Contains the Lifestage from A (Young Singles) to F (Retired).
// $result->GetDemographicsResult->WealthQuartile
// Contains the Affluence Quartile from 1 (Affluent) to 4 (Struggling).
// $result->GetDemographicsResult->WealthRanking
// Contains the Wealth Ranking from 1 (Wealthiest) to 100 (Poorest)
// $result->GetDemographicsResult->Description
// Contains a detailed textual description for the type of person that typically lives in this postcode
}
}