定制 pippa/notification-sdk-curl 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

pippa/notification-sdk-curl

最新稳定版本:1.0.3

Composer 安装命令:

composer require pippa/notification-sdk-curl

包简介

Notification Service SDK for plain PHP — zero dependencies, pure cURL

README 文档

README

Pure PHP SDK for the Notification Service API.
Zero dependencies — works in any PHP 8.1+ environment without Laravel or Guzzle.

Installation

composer require Pippa\notification-sdk-curl

Setup

<?php
require 'vendor/autoload.php';

use Pippa\NotificationSdkCurl\NotificationClient;

$client = new NotificationClient(
    apiKey:    'your_api_key',
    secretKey: 'your_secret_key',
);

Usage

Send Email

$response = $client->sendEmail(
    email:    'user@example.com',
    template: 'welcome_email',
    data:     ['name' => 'Rahim']
);

Send SMS

$response = $client->sendSms(
    phone:    '+8801700000000',
    template: 'otp_sms',
    data:     ['otp' => '1234']
);

Send In-App Notification

$response = $client->sendInApp(
    userId:   'user_123',
    template: 'order_update',
    data:     ['order_id' => 'ORD-456', 'status' => 'Shipped']
);

Multi-channel (Courier-style)

use Pippa\NotificationSdkCurl\Requests\SendMessageRequest;
use Pippa\NotificationSdkCurl\DTOs\TemplateMessage;
use Pippa\NotificationSdkCurl\DTOs\Recipient;

$response = $client->send(
    new SendMessageRequest([
        'message' => new TemplateMessage([
            'to' => [
                Recipient::email('user@example.com'),
                Recipient::phone('+8801700000000'),
                Recipient::userId('user_123'),
            ],
            'template' => 'welcome_notification',
            'data'     => ['name' => 'Rahim'],
        ]),
    ])
);

if ($response->isSuccess()) {
    echo 'Sent! ID: ' . $response->getRequestId();
}

Exception Handling

use Pippa\NotificationSdkCurl\Exceptions\NotificationException;

try {
    $client->sendEmail('user@example.com', 'my_template');
} catch (NotificationException $e) {
    echo $e->getMessage();   // error message
    echo $e->getCode();      // HTTP status code
    print_r($e->getErrors()); // validation errors array
}

Available Methods

Method Description
send(SendMessageRequest) Full control
sendEmail($email, $template, $data) Send email via template
sendSms($phone, $template, $data) Send SMS via template
sendInApp($userId, $template, $data) Send in-app notification
sendMulti($recipients[], $template, $data) Multi-channel, multi-recipient

Recipient Helpers

use Pippa\NotificationSdkCurl\DTOs\Recipient;

Recipient::email('user@example.com')
Recipient::phone('+8801700000000')
Recipient::userId('user_123')
Recipient::make(['email' => '...', 'phone' => '...', 'user_id' => '...'])
Recipient::make([...])->only(['email', 'sms'])  // restrict channels

License

MIT

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固