wirepusher/sdk
最新稳定版本:v1.0.0-alpha.1
Composer 安装命令:
composer require wirepusher/sdk
包简介
Official WirePusher SDK for PHP
README 文档
README
Official PHP client for WirePusher push notifications.
Installation
composer require wirepusher/sdk
Quick Start
use WirePusher\Client;
// Auto-load token from WIREPUSHER_TOKEN env var
$client = new Client();
$client->send('Deploy Complete', 'Version 1.2.3 deployed');
// Or provide token explicitly
$client = new Client(token: 'YOUR_TOKEN');
$client->send('Alert', 'Server CPU at 95%');
Features
use WirePusher\SendOptions;
// Full parameters
$options = new SendOptions(
title: 'Deploy Complete',
message: 'Version 1.2.3 deployed',
type: 'deployment',
tags: ['production', 'backend'],
imageUrl: 'https://example.com/success.png',
actionUrl: 'https://example.com/deploy/123',
);
$client->send($options);
// AI-powered notifications (NotifAI)
$response = $client->notifai('deployment finished, v2.1.3 is live');
echo $response->notification->title; // AI-generated
echo $response->notification->message;
// Encrypted messages
$options = new SendOptions(
title: 'Security Alert',
message: 'Sensitive data',
type: 'security',
encryptionPassword: 'your_password',
);
$client->send($options);
Configuration
// Environment variables (recommended)
// WIREPUSHER_TOKEN - API token (required if not passed to constructor)
// WIREPUSHER_TIMEOUT - Request timeout in seconds (default: 30)
// WIREPUSHER_MAX_RETRIES - Retry attempts (default: 3)
// Or explicit configuration
$client = new Client(
token: 'YOUR_TOKEN',
timeout: 60.0,
maxRetries: 5,
);
Error Handling
use WirePusher\Client;
use WirePusher\Exceptions\AuthenticationException;
use WirePusher\Exceptions\ValidationException;
use WirePusher\Exceptions\RateLimitException;
try {
$client = new Client();
$client->send('Title', 'Message');
} catch (AuthenticationException $e) {
echo "Invalid token";
} catch (ValidationException $e) {
echo "Invalid parameters";
} catch (RateLimitException $e) {
echo "Rate limited - auto-retry handled this";
}
Automatic retry with exponential backoff for network errors, 5xx, and 429 (rate limit).
Smart Rate Limiting
The library automatically handles rate limits with Retry-After header support:
$client = new Client();
$client->send('Alert', 'Message');
// Check rate limit status after any request
$rateLimit = $client->getLastRateLimit();
if ($rateLimit !== null) {
echo "Remaining: {$rateLimit->remaining}/{$rateLimit->limit}";
echo "Resets at: {$rateLimit->reset}";
}
See Advanced Documentation for detailed rate limit monitoring patterns.
Links
- Get Token: App → Settings → Help → copy token
- Documentation: https://wirepusher.dev/help
- Repository: https://gitlab.com/wirepusher/wirepusher-php
- Packagist: https://packagist.org/packages/wirepusher/sdk
License
MIT
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-17