notify-events / php
PHP 扩展,用于将您的项目与 Notify.Events 服务集成。
v1.1.0
2022-08-13 11:07 UTC
Requires
- php: >=5.5
- ext-json: *
Suggests
- ext-curl: For sending via Curl
- ext-fileinfo: Autodetect mime-type for file/image uploads
This package is auto-updated.
Last update: 2024-09-13 15:53:52 UTC
README
这是一个简单的 PHP 扩展,简化了将您的项目与 Notify.Events 服务集成以发送消息到您的渠道的过程。
其他语言说明
安装
安装此扩展的首选方式是通过 composer。
运行以下命令
php composer.phar require --prefer-dist notify-events/php
或者
"notify-events/php": "~1.0"
将其添加到 composer.json 的 require 部分。
用法
要使用此扩展,您需要在您的 PHP 脚本中导入 Message 类。
如果您使用 composer 进行安装,则只需包含 autoload.php 文件即可
require_once "vendor/autoload.php";
否则,如果您手动添加了扩展,您需要自行导入 Message 类
require_once "path/to/notify-events/php/Message.php";
之后,您可以创建一个消息对象,设置必要的参数并将消息发送到渠道。
用法示例
<?php require_once "vendor/autoload.php"; // Defining channel token. // You get this token when creating a channel on the Notify.Events service. $myChannelToken = 'XXXXXXXX'; // Create a message object. $message = new Message('Some <b>important</b> message', 'Title', Message::PRIORITY_HIGH, Message::LEVEL_ERROR); // Attach the file to the message. $message->addFile('path\to\local\file'); // Send a message to your channel in Notify.Events. $message->send($myChannelToken); ?>