Identifies a country from a customer's contact details. All the available details for the customer should be supplied as part of the CountryDetectionInput structure passed as the request argument.
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 CountryDetection Integr8 service
data8.load('CountryDetection');
}
function DetectCountry(request) {
/// <param name="request">data8.countrydetectioninput. Set up the Address, Postcode, Country, EmailAddresses, TelephoneNumbers properties before calling this method.</param>
var countrydetection = new data8.countrydetection();
countrydetection.detectcountry(
request,
null,
showDetectCountryResult
);
}
function showDetectCountryResult(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.CountryName
// Contains the ISO standard name of the detected country
// result.CountryISO
// Contains the 2-character ISO code of the detected country
}
}
loadIntegr8();
</script>
// NOTE: A reference to the web service must be added in Visual Studio with the URL
// http://webservices.data-8.co.uk/CountryDetection.asmx
private void DetectCountry(CountryDetectionInput request)
{
// Invoke the web service method.
CountryDetection proxy = new CountryDetection();
CountryDetectionOutput results = proxy.DetectCountry("username", "password", request, 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.CountryName
// Contains the ISO standard name of the detected country
// result.CountryISO
// Contains the 2-character ISO code of the detected country
}
}
'NOTE: A reference to the web service must be added in Visual Studio with the URL
'http://webservices.data-8.co.uk/CountryDetection.asmx
Private Sub DetectCountry(ByVal request As CountryDetectionInput)
'Invoke the web service method.
Dim proxy As CountryDetection = New CountryDetection()
Dim results As CountryDetectionOutput = proxy.DetectCountry("username", "password", request, 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.CountryName
' Contains the ISO standard name of the detected country
'result.CountryISO
' Contains the 2-character ISO code of the detected country
End If
End Sub
Public Sub DetectCountry(address As String, postcode As String, country As String, emailAddresses As String, telephoneNumbers As String)
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "http://webservices.data-8.co.uk/recordset.ashx?service=CountryDetection&method=DetectCountrySimple" &
"&username=your-username" &
"&password=your-password" &
"&address=" & address &
"&postcode=" & postcode &
"&country=" & country &
"&emailAddresses=" & emailAddresses &
"&telephoneNumbers=" & telephoneNumbers
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:
'CountryName
' Contains the ISO standard name of the detected country
'CountryISO
' Contains the 2-character ISO code of the detected country
End If
End If
End Sub
// NOTE: The php_soap.dll extension must be enabled in the php.ini file.
function DetectCountry($request)
{
$params = array(
"username" => "your-username",
"password" => "your-password",
"request" => $request,
"options" => $options
);
$client = new SoapClient("http://webservices.data-8.co.uk/CountryDetection.asmx?WSDL");
$result = $client->DetectCountry($params);
if ($result->DetectCountryResult->Status->Success == 0)
{
echo "Error: " . $result->DetectCountryResult->Status->ErrorMessage;
}
else
{
// TODO: Process method results here.
// Results can be extracted from the following fields:
// $result->DetectCountryResult->CountryName
// Contains the ISO standard name of the detected country
// $result->DetectCountryResult->CountryISO
// Contains the 2-character ISO code of the detected country
}
}