PHP code example of andrey-helldar / blacklist-client
1. Go to this page and download the library: Download andrey-helldar/blacklist-client 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/ */
andrey-helldar / blacklist-client example snippets
/*
* DATABASE
* [email protected] - exists
* [email protected] - not exists
*/
use Helldar\BlacklistClient\Facades\Client;
return Client::check('http://example.com'); // false
return Client::check('192.168.1.1'); // false
return Client::check('+0 (000) 000-00-00'); // false
return Client::check('[email protected]');
/* GuzzleHttp\Exception\ClientException with 423 code and content:
*
* {"error":{"code":400,"msg":["Checked [email protected] was found in our database.]}}
*/
use GuzzleHttp\Exception\ClientException;
use Helldar\BlacklistClient\Facades\Client;
class Foo
{
public function store(array $data)
{
if (! $this->isSpammer($data['email'])) {
// storing data
}
}
private function isSpammer(string $value): bool
{
try {
return Client::check($value);
}
catch (ClientException $exception) {
return true;
}
}
}