TIPS & TRICKS

PHP integration sample with MightyVerify

December 08, 2013

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";
}

0 Comments
0 Likes
Share

Comments (0)

Newest First
Subscribe via email
Preview
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form
Powered by txtmeQuick