Symfony 1 plugin to support the PostcodeAnywhere API
You will need to register an account with PostcodeAnywhere.
Copy or rename the app.yml.dist
file to app.yml
, or copy the content to your project or application app.yml
.
Fill in the details (minimum required is licence key, obtained from PostcodeAnywhere).
Alternatively you can provide the details when constructing the object: new sfPostcodeAnywhere('accountCode', 'licenceKey', 'serviceUrl')
$pa = new sfPostcodeAnywhere();
$isValid = $pa->validateEmail('[email protected]');
You can also capture back which bits of the email validator passed/failed - this can be used if you only care about syntax and not if there is a valid mail server, etc.
$pa = new sfPostcodeAnywhere();
$pa->validateEmail('[email protected]', $result);
$isValid = $result['ValidFormat'];
$pa = new sfPostcodeAnywhere();
$isValid = $pa->validateAddressUK($results, 'AA11 1AA');
The results array will contain a list of all the address found against the supplied postcode (if valid).
You can also validate that a place or street address exists for a given postcode.
$pa = new sfPostcodeAnywhere();
$isValid = $pa->validateAddressUK($results, 'AA11 1AA', 'Some Town', '1 Some Road');
Implement the rest of the API calls.