apiddress/sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

apiddress/sdk

Composer 安装命令:

composer require apiddress/sdk

包简介

Official PHP SDK for the APIddress email validation API

README 文档

README

Official PHP SDK for the APIddress email validation API.

  • Zero Composer runtime dependencies (stdlib curl extension only)
  • PHP 8.1+, fully typed with readonly properties, PSR-4 autoloading
  • Automatic retry with backoff on 429 and 5xx (batch creation is never retried)

Install

composer require apiddress/sdk

Quickstart

use Apiddress\Client;

$client = new Client($_ENV['APIDDRESS_API_KEY']);

$result = $client->validateEmail('ada@stripe.com');
echo $result->status; // "valid"
echo $result->score;  // 0.98

Configuration

$client = new Client(
    apiKey:     'YOUR_API_KEY',
    baseUrl:    'https://api.apiddress.com', // default
    timeout:    10,                          // per-request timeout (seconds), default 10
    maxRetries: 2,                           // retries on 429/5xx, default 2
);

Usage

Validate one email

$result = $client->validateEmail(
    'john@company.com',
    checkSmtp:      false, // default
    allowRoleBased: true,  // server default
);
// $result->status: "valid" | "invalid" | "risky" | "disposable" | "unknown"
// $result->suggestion: "john@gmail.com" for typo-like addresses, else null
// $result->checks: ValidationChecks { syntax, domain_exists, mx, smtp, disposable, ... }

A malformed value (e.g. "not-an-email") is a verdict, not an error: you get status === "invalid" with reason === "invalid_syntax".

Validate up to 100 emails synchronously

$response = $client->validateEmails(['a@example.com', 'b@example.com']);
echo $response->count;
foreach ($response->results as $r) {
    echo $r->email . ' ' . $r->status . PHP_EOL;
}

Batch jobs (up to 5000 emails)

$batch = $client->createBatch(
    $emails,
    callbackUrl: 'https://yourapp.com/webhooks/apiddress', // optional
);

$done = $client->waitForBatch(
    $batch->batch_id,
    pollInterval: 1.0,  // default
    timeout:      60.0, // default
);
echo $done->status . ' ' . count($done->results);

// Or poll yourself:
$status = $client->getBatch($batch->batch_id);

waitForBatch returns the terminal state ("completed" or "failed") — check status before using results.

Account

$profile = $client->me();           // plan, limits, usage
$usage   = $client->usage();        // current month
$may     = $client->usage('2026-05'); // specific month
$health  = $client->health();       // no auth required

Error handling

Every failed request throws an APIddressError:

use Apiddress\APIddressError;
use Apiddress\Client;

try {
    $client->validateEmail('john@company.com');
} catch (APIddressError $err) {
    echo $err->status;  // 429
    echo $err->code;    // "quota_exceeded"
    echo $err->getMessage(); // "Monthly request limit exceeded."
    var_dump($err->details); // ["requests_used" => ..., "requests_limit" => ...]
}
status code
400 invalid_request
401 unauthorized
404 not_found
429 quota_exceeded
500 internal_error
0 timeout (request or waitForBatch timeout)

Development

composer install
composer exec phpunit

# Integration tests need a live backend:
APIDDRESS_BASE_URL=http://localhost:3000 APIDDRESS_API_KEY=test_key_local_dev \
  composer exec phpunit

License

MIT

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固