NOTICE: this example is provided for informational purposes only.
We do not provide custom integration services or development support.
#!/usr/bin/php
<?php
$apikey="<PUT YOUR KEY HERE-->";
/*
* Make sure args are passed
*/
if($argc!=2) {
print "Usage: ".$argv[0]." emailaddress@domain.com\n";
exit(1);
}
/*
* Set up cURL
*/
$c=curl_init("http://bpi.mightyverify.com/emails.json?apikey=$apikey&address=".urlencode($argv[1]));
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FAILONERROR, false);
curl_setopt($c, CURLOPT_TIMEOUT, 5);
/*
* Run cURL, parse info, and close it
*/
$results=curl_exec($c);
$info=curl_getinfo($c);
curl_close($c);
/*
* decode the JSON results
*/
$answer=json_decode($results);
/*
* Make sure you have a valid HTTP status code, and it parsed into the expected JSON object
*/
if($info['http_code'] && isset($answer->status)) {
print "The email ".$argv[1]." has a status of: ".$answer->status."\n";
if($answer->status=="invalid") {
print "Address is invalid, encourage your user to correct his or her address\n";
} else {
print "Permit the user through\n";
}
} else {
print "Could not talk to BV servers - allow the address through as 'unknown'\n";
}