-
-
Save elclanrs/301f4298189203b2fc77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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://api.briteverify.com/emails/verify.js?apikey=$apikey&email[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->email)) { | |
print "The email ".$argv[1]." has a status of: ".$answer->email->status."\n"; | |
if($answer->email->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"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment