예제 #1
0
if (!file_exists('../vendor/autoload.php')) {
    die("Run 'composer install' from the command line");
}
error_reporting(E_ALL);
ini_set('display_errors', 1);
// This is to help new users to Composer
require_once '../vendor/autoload.php';
use AntiMattr\AddressVerifier\Event\EventFactory;
use AntiMattr\AddressVerifier\Client\BriteVerifyClient as Verifier;
use Buzz\Client\Curl as RestClient;
use Buzz\Message\Factory\Factory as MessageFactory;
$secretKey = 'YOUR-API-KEY';
$buzz = new RestClient();
$eventFactory = new EventFactory();
$messageFactory = new MessageFactory();
$client = new Verifier($secretKey, $buzz, $eventFactory, $messageFactory);
$email = '*****@*****.**';
$error = '';
$success = '';
$correction = null;
if ($_POST) {
    try {
        if (!isset($_POST['email'])) {
            throw new \Exception("The email not submitted");
        }
        $email = $_POST['email'];
        $client->verifyEmail($email);
        $success = 'Your email was verified.';
    } catch (\Exception $e) {
        $error = sprintf('%s: %s', get_class($e), $e->getMessage());
    }
}
error_reporting(E_ALL);
ini_set('display_errors', 1);
// This is to help new users to Composer
require_once '../vendor/autoload.php';
use AntiMattr\AddressVerifier\Event\EventFactory;
use AntiMattr\AddressVerifier\Exception\Location\CorrectionException;
use AntiMattr\AddressVerifier\Client\BriteVerifyClient as Verifier;
use AntiMattr\Common\Address\GenericAddress as Address;
use Buzz\Client\Curl as RestClient;
use Buzz\Message\Factory\Factory as MessageFactory;
$secretKey = 'YOUR-API-KEY';
$buzz = new RestClient();
$eventFactory = new EventFactory();
$messageFactory = new MessageFactory();
$client = new Verifier($secretKey, $buzz, $eventFactory, $messageFactory);
$address = new Address();
$error = '';
$success = '';
$correction = null;
if ($_POST) {
    try {
        if (!isset($_POST['address'])) {
            throw new \Exception("The address not submitted");
        }
        $data = $_POST['address'];
        $address->setStreetAddressLine1($data['streetAddressLine1']);
        $address->setStreetAddressLine2($data['streetAddressLine2']);
        $address->setLocality($data['locality']);
        $address->setRegion($data['region']);
        $address->setPostalCode($data['postalCode']);