PHP code example of asamoahboateng / academic-email-verifier
1. Go to this page and download the library: Download asamoahboateng/academic-email-verifier 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/ */
asamoahboateng / academic-email-verifier example snippets
use AcademicEmailVerifier\AcademicEmailVerifier;
$verifier = new AcademicEmailVerifier();
// Verify an academic email
$result = $verifier->verify('[email protected]');
// Check the result
if ($result['is_academic']) {
echo "This is an academic email from: " . $result['university'];
} else {
echo "Error: " . $result['error'];
}
use AcademicEmailVerifier\AcademicEmailVerifier;
$verifier = new AcademicEmailVerifier();
// Add multiple domain exceptions
$verifier->addDomainException('custom.edu', 'Custom University');
$verifier->addDomainException('research.org', 'Research Institute');
$verifier->addDomainException('college.ac.uk', 'British College');
// You can add as many as you need
$verifier->addDomainException('university.edu.gh', 'Ghana University');
$verifier->addDomainException('institute.co.za', 'South African Institute');
// Get all domain exceptions
$exceptions = $verifier->getDomainExceptions();
// Result will contain all added exceptions:
// [
// 'custom.edu' => ['name' => 'Custom University', 'domains' => ['custom.edu']],
// 'research.org' => ['name' => 'Research Institute', 'domains' => ['research.org']],
// 'college.ac.uk' => ['name' => 'British College', 'domains' => ['college.ac.uk']],
// 'university.edu.gh' => ['name' => 'Ghana University', 'domains' => ['university.edu.gh']],
// 'institute.co.za' => ['name' => 'South African Institute', 'domains' => ['institute.co.za']]
// ]
// Remove specific exceptions
$verifier->removeDomainException('research.org');
// Clear all exceptions if needed
$verifier->clearDomainExceptions();
// Academic email
$result = $verifier->verify('[email protected]');
// Result:
// [
// 'is_academic' => true,
// 'university' => 'Harvard University',
// 'error' => null
// ]
// Non-academic email
$result = $verifier->verify('[email protected]');
// Result:
// [
// 'is_academic' => false,
// 'university' => null,
// 'error' => 'Domain not found in academic institutions database'
// ]
// Invalid email format
$result = $verifier->verify('invalid-email');
// Result:
// [
// 'is_academic' => false,
// 'university' => null,
// 'error' => 'Invalid email format'
// ]