smartpings/php-sdk 问题修复 & 功能扩展

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

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

smartpings/php-sdk

Composer 安装命令:

composer require smartpings/php-sdk

包简介

Smartpings Messaging Service

README 文档

README

This is the official PHP SDK for the SmartPings API.

Installation

You can install the package via composer:

composer require smartpings/php-sdk

Getting Started

The easiest way to use the service is by using the static create method. This will automatically set up the required HTTP client for you.

use Smartpings\Messaging\SmartpingsService; // Instantiate the service with your credentials $service = SmartpingsService::create( 'your-client-id', 'your-secret-id' ); // Now you can use the service methods

Available Methods

Send an SMS

The sendSms method can send a message to a single phone number or an array of phone numbers.

// Send to a single recipient $response = $service->sendSms('Your message here', 'recipient-phone-number'); // Send to multiple recipients $response = $service->sendSms('Your message here', [ 'recipient-1-phone-number', 'recipient-2-phone-number', ]); if ($response->getStatusCode() === 200) { echo "SMS sent successfully!"; }

Contact Verification

Generic Verification Method

The verifyContact method handles both phone and email verification:

// Send verification codes $service->verifyContact('phone', '+15551234567'); $service->verifyContact('email', 'user@example.com'); // Verify with codes $service->verifyContact('phone', '+15551234567', 'user-provided-code'); $service->verifyContact('email', 'user@example.com', 'verification-token'); // With additional options $service->verifyContact( type: 'email', contact: 'user@example.com', code: null, name: 'John Doe', redirectUrl: 'https://yourapp.com/verify', expirationMinutes: 15, promoteToListIds: [1, 2, 3] );

Convenience Methods

For cleaner, type-specific verification:

// Phone verification $service->sendPhoneVerification('+15551234567', 'John Doe'); $service->verifyPhoneWithCode('+15551234567', '123456'); // Email verification $service->sendEmailVerification('user@example.com', 'John Doe'); $service->verifyEmailWithCode('user@example.com', 'verification-token');

Check Verification Status

Monitor verification status for any contact:

$response = $service->getContactVerificationStatus('user@example.com'); if ($response->getStatusCode() === 200) { $data = json_decode($response->getBody()->getContents(), true)['data']; // Status: 'pending', 'verified', or 'expired' echo "Status: {$data['status']}, Verified: " . ($data['verified'] ? 'Yes' : 'No'); }

Advanced Usage

If you need to customize the HTTP client (e.g., to add custom middleware, logging, or timeout settings), you can instantiate the SmartpingsService manually by passing any PSR-18 compatible client and PSR-17 compatible factories.

use GuzzleHttp\Client; use GuzzleHttp\Psr7\HttpFactory; use Smartpings\Messaging\SmartpingsService; // 1. Create a PSR-18 HTTP Client $client = new Client(['timeout' => 5.0]); // 2. Create a PSR-17 Factory $httpFactory = new HttpFactory(); // 3. Instantiate the service $service = new SmartpingsService( $client, // Your custom client $httpFactory, // Request factory $httpFactory, // Stream factory 'https://api.smartpings.com/api/', // API URL 'your-client-id', 'your-secret-id' ); // The service is ready to use $response = $service->sendSms('Your message here', 'recipient-phone-number');

Laravel Integration

This package includes a service provider for seamless integration with Laravel.

How It Works

The package will automatically register a service provider that instantiates the SmartpingsService for you. The provider uses the static create() method and configures it with the credentials you set in your .env file.

This allows you to inject the SmartpingsService directly into your controllers or other services, and it will be ready to use.

Configuration

  1. Add your credentials to your .env file:

    SMARTPINGS_CLIENT_ID=your-client-id SMARTPINGS_SECRET_ID=your-secret-id
  2. Publish the configuration file (optional):

    If you need to customize the API URL or other settings, you can publish the configuration file:

    php artisan vendor:publish --provider="Smartpings\Messaging\SmartpingsServiceProvider"

    This will create a config/smartpings.php file in your application.

Usage Example

Once configured, you can inject the SmartpingsService anywhere in your Laravel application.

use Smartpings\Messaging\SmartpingsService; class YourController { public function __construct(private SmartpingsService $smartpingsService) { } public function sendMessage() { $response = $this->smartpingsService->sendSms( 'Your message here', 'recipient-phone-number' ); if ($response->getStatusCode() === 200) { // Message sent successfully } } }

smartpings/php-sdk 适用场景与选型建议

smartpings/php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 353 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04