onesignal/onesignal-php-api
Composer 安装命令:
composer require onesignal/onesignal-php-api
包简介
A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
关键字:
README 文档
README
Building with an AI agent or LLM? See AGENTS.md for an agent-oriented integration guide — authentication, calling conventions, idempotent retries, and the full API reference.
A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
For more information, please visit https://onesignal.com.
- API version: 5.9.0
- Package version: 5.9.0
Requirements
PHP 7.3 and later.
Installation
Add the following to composer.json:
{
"require": {
"onesignal/onesignal-php-api": "^5.3"
}
}
Then run composer update.
Configuration
Every SDK requires authentication via API keys. Two key types are available:
- REST API Key — required for most endpoints (sending notifications, managing users, etc.). Found in your app's Settings > Keys & IDs.
- Organization API Key — only required for organization-level endpoints like creating or listing apps. Found in Organization Settings.
Warning: Store your API keys in environment variables or a secrets manager. Never commit them to source control.
use onesignal\client\api\DefaultApi; use onesignal\client\Configuration; use GuzzleHttp; $config = Configuration::getDefaultConfiguration() ->setRestApiKeyToken('YOUR_REST_API_KEY') ->setOrganizationApiKeyToken('YOUR_ORGANIZATION_API_KEY'); $client = new DefaultApi( new GuzzleHttp\Client(), $config );
Send a push notification
use onesignal\client\model\Notification; use onesignal\client\model\StringMap; $content = new StringMap(); $content->setEn('Hello from OneSignal!'); $headings = new StringMap(); $headings->setEn('Push Notification'); $notification = new Notification(); $notification->setAppId('YOUR_APP_ID'); $notification->setContents($content); $notification->setHeadings($headings); $notification->setIncludedSegments(['Subscribed Users']); $response = $client->createNotification($notification); echo 'Notification ID: ' . $response->getId();
Send an email
$notification = new Notification(); $notification->setAppId('YOUR_APP_ID'); $notification->setEmailSubject('Important Update'); $notification->setEmailBody('<h1>Hello!</h1><p>This is an HTML email.</p>'); $notification->setIncludedSegments(['Subscribed Users']); $notification->setChannelForExternalUserIds('email'); $response = $client->createNotification($notification);
Send an SMS
$content = new StringMap(); $content->setEn('Your SMS message content here'); $notification = new Notification(); $notification->setAppId('YOUR_APP_ID'); $notification->setContents($content); $notification->setIncludedSegments(['Subscribed Users']); $notification->setChannelForExternalUserIds('sms'); $notification->setSmsFrom('+15551234567'); $response = $client->createNotification($notification);
Full API reference
The complete list of API endpoints and their parameters is available in the DefaultApi documentation.
For the underlying REST API, see the OneSignal API reference.
onesignal/onesignal-php-api 适用场景与选型建议
onesignal/onesignal-php-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 221.31k 次下载、GitHub Stars 达 35, 最近一次更新时间为 2022 年 11 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「rest」 「api」 「sdk」 「onesignal」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 onesignal/onesignal-php-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 onesignal/onesignal-php-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 onesignal/onesignal-php-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
Alfabank REST API integration
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
BlockCypher's PHP SDK for REST API
Helper classes for creating cookie headers
统计信息
- 总下载量: 221.31k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 36
- 点击次数: 38
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2022-11-23