PHP code example of versium / reach-api-php-sdk

1. Go to this page and download the library: Download versium/reach-api-php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

versium / reach-api-php-sdk example snippets


use Versium\Reach\ReachClient;

$loggingFunction = function($msg) {
    //print out message for dev
    echo $msg;
};
$client = new ReachClient('you-api-key', $loggingFunction);

//call the contact API to append phones and emails 
$inputs = [
    [
        'first' => 'john',
        'last' => 'doe',
        'address' => '123 Trinity St',
        'city' => 'Redmond',
        'state' => 'WA',
        'zip' => '98052',
    ]
];

foreach ($client->append('contact', $inputs, ['email', 'phone']) as $results) {
    //filter out failed queries for processing later
    $failedResults = array_filter($results, function ($result) {
        return !$result->success;
    });
    
    //merge successful matches with inputs
    foreach ($results as $idx => $result) {
        if ($result->matchFound) {
            $inputs[$idx]['appendResults'] = $result->body->versium->results;
        }        
    }
}

$result = $client->listgen('abm', ['domain' => ['versium.com']], ['abm_email', 'abm_online_audience']);

if ($result->success) {
    foreach (($result->getRecordsFunc)() as $record) {
        var_dump($record);
    }
}