Documentação · PHP
PHP tem 2 caminhos: cURL nativo (zero dependência, mais verboso) ou Guzzle (padrão moderno, requer composer). Os exemplos abaixo usam Guzzle pela legibilidade — versão cURL no final das notas.
composer require guzzlehttp/guzzleSingle · POST /validate/single
Endpoint síncrono. Retorna em 1–3 segundos com result, score, reason e atributos. Custa 1 crédito por chamada bem-sucedida.
<?php
// validate_single.php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
$apiKey = getenv('EMAILCHECKER_API_KEY');
$baseUrl = 'https://app.emailchecker.email/api/v1';
$client = new Client([
'base_uri' => $baseUrl,
'timeout' => 15.0,
'headers' => [
'Authorization' => "Bearer {$apiKey}",
'Content-Type' => 'application/json',
],
]);
function validateEmail(Client $client, string $email): array {
try {
$response = $client->post('/validate/single', [
'json' => ['email' => $email],
]);
return json_decode((string) $response->getBody(), true);
} catch (RequestException $e) {
throw new \RuntimeException("EmailChecker API error: " . $e->getMessage());
}
}
// uso
$result = validateEmail($client, 'joao@empresa.com.br');
echo $result['result']; // "deliverable" | ...
echo $result['score']; // 0-100Batch · POST /validate/batch
Endpoint async. Submete array de emails, retorna job_id. Use webhook (recomendado) ou polling pra pegar resultado. Suporta até 100k emails por job.
<?php
// validate_batch.php
function submitBatch(Client $client, array $emails, ?string $webhookUrl = null): string {
$payload = ['emails' => $emails];
if ($webhookUrl) {
$payload['webhook_url'] = $webhookUrl;
}
$response = $client->post('/validate/batch', ['json' => $payload]);
$data = json_decode((string) $response->getBody(), true);
return $data['job_id'];
}
function getBatchResult(Client $client, string $jobId): array {
$response = $client->get("/validate/batch/{$jobId}");
return json_decode((string) $response->getBody(), true);
}
// uso
$jobId = submitBatch($client, ['a@x.com', 'b@y.com'], 'https://seu-app.com/webhook/ec');Webhook handler
Quando o batch termina, a gente faz POST pra URL que você passou em webhook_url. Retry automático em até 3 tentativas (1s, 5s, 30s) se você responder com erro 5xx.
<?php
// webhook.php (PHP nativo, sem framework)
$input = json_decode(file_get_contents('php://input'), true);
if ($input['status'] !== 'completed') {
http_response_code(200);
echo json_encode(['ok' => true]);
exit;
}
foreach ($input['results'] as $r) {
if ($r['result'] === 'deliverable') {
// salva no banco, dispara worker, etc.
}
}
http_response_code(200);
echo json_encode(['ok' => true]);Mais linguagens
Comece grátis com 500 créditos. Sem cartão, sem compromisso.