Phonematch web service PHP example

The following PHP code example enables you to easily get up and running with the Phonematch web service. Simply use the authentication credentials supplied to you on sign up which we have made available to you in the My Account section.

You will likely prefer to use one of of the available OAuth libraries to handle client authentication. Our example below makes use of PHP's OAuth extension.

Whilst our code examples demonstrate the breadth of our capabilities, all of our examples are created using demo data and do not contain real or live personal data relating to data subjects.

$subject = array(
    'landlineService'  => 'A',
    'mobileService'    => 'A',
    'forename'         => 'Heather',
    'middleName'       => 'Jane',
    'surname'          => 'Russell',
    'address1'         => '201 Julius Road',
    'address2'         => 'Bristol',
    'address3'         => '',
    'address4'         => '',
    'address5'         => '',
    'postcode'         => 'BS7 8EU',
    'requestReference' => 'My Unique Reference',
    'ignore'           => '07777111112',
// Your consumer key and secret as supplied by Tracesmart
$consumerKey    = 'b8e601941ad09b9478ac76c25b3bb46e10b8bdad';
$consumerSecret = '3065d6fa76t2da717bc5765388a8795a45245583';
try {
    $oauth = new OAuth(
        $consumerKey, $consumerSecret,
    // This is a live API, please contact us if you need to perform load, volume or security testing
    $oauth->fetch('', $subject);
    $serviceResponse = $oauth->getLastResponse();
} catch(OAuthException $e) {
    echo "Service Response: ". $e->getMessage() . PHP_EOL;
// Your Phonematch search results are now ready to work with
$phonematchResult = json_decode($serviceResponse);

From this juncture you should refer to the higher level documentation which explains how to send a request.