承接 nickdnk/zerobounce-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

nickdnk/zerobounce-php

Composer 安装命令:

composer require nickdnk/zerobounce-php

包简介

OOP integration with the ZeroBounce API.

README 文档

README

example workflow

This library will allow you to integrate the ZeroBounce API in your project using modern PHP7 and an OOP structure.

Prerequisites

You need an active account at https://zerobounce.net to use this library. From there, grab your API Key under API - Keys & Info.

Installation

To include this in your project, install it using Composer.

As we use return types and type hints, this library requires PHP 7.1 and works on all versions up until PHP 8.1

composer require nickdnk/zerobounce-php

Tests

Enter your API key into the ZeroBounceTest file and run it. This uses the test-emails supplied by ZeroBounce and will not cost you credit.

How to use

use nickdnk\ZeroBounce\Email;
use nickdnk\ZeroBounce\Result;
use nickdnk\ZeroBounce\ZeroBounce;

// You can modify the timeout using the second parameter. Default is 15.
// You an also pass proxy options to Guzzle using the third parameter.
// See https://docs.guzzlephp.org/en/stable/request-options.html#proxy for details.
$handler = new ZeroBounce('my_api_key', 30, ['https' => 'https://my-proxy-server']);

$email = new Email(
    
    // The email address you want to check
    'some-email@domain.com',
    
    // and if you have it, the IP address - otherwise null or omitted
    '123.123.123.123'

);

try {

    // Validate the email
    $result = $handler->validateEmail($email);
    
    if ($result->getStatus() === Result::STATUS_VALID) {
        
        // All good
        
        if ($result->isFreeEmail()) {
            
            // Email address is free, such as @gmail.com, @hotmail.com.
            
        }
        
        /**
        * The user object contains metadata about the email address
        * supplied by ZeroBounce. All of these may be null or empty
        * strings, so remember to check for that. 
        */
        $user = $result->getUser();
        
        $user->getCountry();
        $user->getRegion();
        $user->getZipCode();
        $user->getCity();
        $user->getGender();
        $user->getFirstName();
        $user->getLastName();
        
    } else if ($result->getStatus() === Result::STATUS_DO_NOT_MAIL) {
        
        // The substatus code will help you determine the exact issue:
        
        switch ($result->getSubStatus()) {
            
            case Result::SUBSTATUS_DISPOSABLE:
            case Result::SUBSTATUS_TOXIC:
                // Toxic or disposable.
                break;
                
                
            case Result::SUBSTATUS_ROLE_BASED:
                // admin@, helpdesk@, info@ etc; not a personal email
                break;
            
            // ... and so on.
                
        }
        
    } else if ($result->getStatus() === Result::STATUS_INVALID) {
        
        // Invalid email.
        
    } else if ($result->getStatus() === Result::STATUS_SPAMTRAP) {
        
        // Spam-trap.
        
    } else if ($result->getStatus() === Result::STATUS_ABUSE) {
        
        // Abuse.
        
    } else if ($result->getStatus() === Result::STATUS_CATCH_ALL) {
        
        // Address is catch-all; not necessarily a private email.
        
    } else if ($result->getStatus() === Result::STATUS_UNKNOWN) {
        
        // Unknown email status.
       
    }
    
    /*
     * To find out how to use and react to different status and
     * substatus codes, see the ZeroBounce documentation at:
     * https://www.zerobounce.net/docs/?swift#version-2-v2
     */

} catch (\nickdnk\ZeroBounce\HttpException $exception) {

   // ZeroBounce returned an error of some kind. Message is best-effort parsing.
   $exception->getMessage();
   // The response is available here also.
   // The HTTP code is 200 for 400-range problems, such as invalid credentials,
   // so don't rely too much on that. It is included mostly for debugging purposes.
   $exception->getResponse(); 

} catch (\nickdnk\ZeroBounce\ConnectionException $exception) {

   // There was a problem connecting to ZeroBounce or the connection timed out waiting for a reply.
   $exception->getMessage(); // will always return generic "request timed out or failed" message

} catch (\nickdnk\ZeroBounce\APIError $exception) {

   // Base exception. Both HttpException and ConnectionException extend from this, so you can
   // catch this to handle both errors. The somewhat odd naming for this was to avoid
   // introducing breaking changes when HttpException and ConnectionException was added.
   $exception->getMessage();

}

nickdnk/zerobounce-php 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-31