nullform/zerobounce-client 问题修复 & 功能扩展

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

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

nullform/zerobounce-client

Composer 安装命令:

composer require nullform/zerobounce-client

包简介

ZeroBounce API client

README 文档

README

Non official PHP client for ZeroBounce API.

Installation

composer require nullform/zerobounce-client

Usage

Basic

use Nullform\ZeroBounce;

$client = new ZeroBounce\Client($api_key);

try {
    $result = $client->validate($email);
} catch (ZeroBounce\Exceptions\AbstractException $exception) {
    echo $exception->getMessage();
}

Caching

You can cache API responses if you use PSR-6 or PSR-16 caching in your project. Just pass to Client::caching() your cache repository instance, TTL and prefix.

If the cache instance is passed, each successful response will be stored to the cache for the $ttl seconds. With repeated requests with the same parameters, the response will be taken from the cache.

// Set PSR-6 or PSR-16 cache instance, TTL (60) and cache keys prefix (zerobounce_)
$client->caching($cache, 60, 'zerobounce_');

Logging

You can log your API calls by passing your own function to Client::logFunction(). Passed function will be called on every API call. The function takes an instance of \Nullform\ZeroBounce\Client as a parameter. For example:

$log_func = function (ZeroBounce\Client $client) {
    file_put_contents('zerobounce-client.log', print_r($client->lastResponse(), true));
};

$client = new ZeroBounce\Client($api_key);
$client->logFunction($log_func);

$usage = $client->getUsage('2019-01-01');

Or you can just override the Client::log() method that is called on every API call.

Methods

Client::timeout()

Client::timeout( [ int $timeout = null ] ) : int

Timeout (maximum time the request is allowed to take). Get or set value.

Client::caching()

Client::caching( $cache, int $ttl [, string $prefix = '' ] ) : bool

Caching of API responses.

You can pass null to disable caching (default).

Client::logFunction()

Client::logFunction( ?callable $func ) : bool

The function for logging that will be called after every ZeroBounce API call.

The function takes a client instance as a parameter.

Client::lastRequest()

Client::lastRequest( void ) : Http\Request

Get last request.

Client::lastResponse()

Client::lastResponse( void ) : Http\Response

Get last response.

Client::getCredits()

Client::getCredits( void ) : int

Get credit balance. If a -1 is returned, that means your API Key is invalid.

Validation API: Credit Balance

Client::validate()

Client::validate( string $email [, ?string $ip_address = null ] ) : Models\Email

Validate email.

Validation API: Validate Emails

Client::getUsage()

Client::getUsage( mixed $start_date [, mixed $end_date = 'now' ] ) : Models\Usage

Get API usage.

$start_date and $end_date - timestamp or string that the strtotime(), DateTime and date_create() parser understands.

Validation API: API Usage

Client::bulkSendFile()

Client::bulkSendFile( string $filename, string $type, Params\BulkSendFileParams $params ) : Models\BulkFile

Send a csv or txt file for bulk email validation/scoring.

$client = new Client($api_key);
$client->timeout(60);
$params = new Params\BulkSendFileParams();
$params->email_address_column = 2;
$file = $client->bulkSendFile($filename, Models\BulkFile::TYPE_VALIDATION, $params);

Validation API: Send File | AI Scoring API: Send File

Client::bulkFileStatus()

Client::bulkFileStatus( string $file_id, string $type ) : Models\BulkFile

Uploaded file status.

Validation API: File Status | AI Scoring API: File Status

Client::bulkGetFile()

Client::bulkGetFile( string $file_id, string $type [, ?string $output_filename = null ] ) : string

Get the validation/scoring results csv (or zip) file for the file been submitted using sendfile API.

Validation API: Get File | AI Scoring API: Get File

Client::bulkDeleteFile()

Client::bulkDeleteFile( string $file_id, string $type ) : bool

Delete the file that was submitted using sendfile API. File can be deleted only when its status is Complete.

Validation API: Delete File | AI Scoring API: Delete File

Facade

You can use facade for quick email validation and balance check.

use Nullform\ZeroBounce\Facade as ZeroBounce;

try {
    $result = ZeroBounce::validate($api_key, $email);
    $credits = ZeroBounce::getCredits($api_key);
} catch (\Exception $exception) {
    $error = $exception->getMessage();
}

nullform/zerobounce-client 适用场景与选型建议

nullform/zerobounce-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 141 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 12 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「client」 「zerobounce」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nullform/zerobounce-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nullform/zerobounce-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 nullform/zerobounce-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-13