wonderpush / wonderpush-php-lib
WonderPush的PHP库
v2.1.1
2020-05-12 10:33 UTC
Requires
- php: >=5.3.3
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpcompatibility/php-compatibility: ^9.2
- phpunit/phpunit: ~4.8
- satooshi/php-coveralls: ^1.0
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2024-09-04 08:37:29 UTC
README
请访问以下链接获取WonderPush服务的完整文档: https://docs.wonderpush.com/docs.
简介
此项目包含一个用于与WonderPush服务交互的PHP库。它帮助您调用管理API。这与SDK不同,SDK旨在集成到您的应用中并处理与用户的交互。
APIs
WonderPush提供两个API,一个针对用户设备,另一个可选的针对您的服务器和工具。前者被称为REST API,而后者称为管理API。
此工具帮助您调用管理API。
管理API参考
WonderPush管理API的所有参考均可在WonderPush文档页面上找到: https://docs.wonderpush.com/reference.
文档
请访问https://wonderpush.github.io/wonderpush-php-lib 获取最新的文档。
要求
PHP 5.3.3及更高版本。
Composer
您可以通过Composer安装绑定。运行以下命令
composer require wonderpush/wonderpush-php-lib
要使用绑定,请使用Composer的自动加载
require_once('vendor/autoload.php');
手动安装
如果您不想使用Composer,您可以下载最新的版本。然后,为了使用绑定,请包含init.php
文件。
require_once('/path/to/wonderpush-php-lib/init.php');
依赖关系
绑定需要以下扩展才能正常工作
如果您使用Composer,这些依赖项应自动处理。如果您手动安装,您需要确保这些扩展可用。
入门
简单用法如下
$wonderpush = new \WonderPush\WonderPush(WONDERPUSH_ACCESS_TOKEN, WONDERPUSH_APPLICATION_ID); $response = $wonderpush->deliveries()->create( \WonderPush\Params\DeliveriesCreateParams::_new() ->setTargetSegmentIds('@ALL') ->setNotification(\WonderPush\Obj\Notification::_new() ->setAlert(\WonderPush\Obj\NotificationAlert::_new() ->setTitle('Using the PHP library') ->setText('Hello, WonderPush!') )) ); echo $response->getNotificationId();
配置日志记录器
库进行了最少的日志记录,但它可以用一个PSR-3
兼容的记录器进行配置,这样消息就会在那里结束而不是在error_log
$wonderpush->setLogger($logger);
开发
安装依赖项
composer install
测试
如上所述安装依赖项(这将解决PHPUnit),然后您可以运行测试套件
./test
或运行单个测试文件
vendor/bin/phpunit tests/SomeTest.php