donatj/pushover
Composer 安装命令:
composer require donatj/pushover
包简介
Simple Pushover.net client
关键字:
README 文档
README
Pushover PHP is a very light, simple API wrapper for the Pushover API written for PHP.
Requirements
- php: >=7.4
- ext-json: *
Installing
Install the latest version with:
composer require 'donatj/pushover'
Usage
<?php require __DIR__ . '/../vendor/autoload.php'; use donatj\Pushover\Exceptions\ResponseException; use donatj\Pushover\Options; use donatj\Pushover\Priority; use donatj\Pushover\Pushover; use donatj\Pushover\Sounds; $po = new Pushover('{my_apikey}', '{my_userkey}'); try { // Simplest example $po->send('Hello World'); // With Options: $po->send('Awesome website, great job!', [ Options::TITLE => 'New Comment!', Options::URL => 'https://donatstudios.com/CsvToMarkdownTable', Options::PRIORITY => Priority::HIGH, Options::SOUND => Sounds::ALIEN, ]); }catch( ResponseException $e ) { // Handle exception }
Documentation
For documentation about the protocol specifics, see the official Pushover API Documentation.
On success Pushover->send returns a truth-y array like:
[
'status' => '1',
'request' => '2f4e9c7140df52d7d8b16ffb8adf1c2a',
]
On failure Pushover->send returns false which allows simple
if( !$po->send('Hello World!') ) { die('oh no!'); }
Class: donatj\Pushover\Exceptions\ResponseException
<?php namespace donatj\Pushover\Exceptions; class ResponseException { public const ERROR_CONNECTION_FAILED = 100; public const ERROR_DECODE_FAILED = 200; public const ERROR_UNEXPECTED = 300; public const ERROR_API = 400; }
Class: donatj\Pushover\Options
Contains available option keys for the Pushover API
<?php namespace donatj\Pushover; class Options { /** * The Application API token. * * Defaults to the token \donatj\Pushover\Pushover was constructed with. */ public const TOKEN = 'token'; /** * The User Key. * * Defaults to the user key \donatj\Pushover\Pushover was constructed with. */ public const USER = 'user'; /** To enable HTML formatting, include HTML parameter set to 1. May not be used if monospace is used. */ public const HTML = 'html'; /** To enable Monospace formatting, include HTML parameter set to 1. May not be used if html is used. */ public const MONOSPACE = 'monospace'; /** * The optional devices name for the message to be pushed to. * * If unspecified, your message will be pushed to all devices. */ public const DEVICE = 'device'; /** The optional message title */ public const TITLE = 'title'; /** The optional message url */ public const URL = 'url'; /** The optional message url title. Must specify a URL as well. */ public const URL_TITLE = 'url_title'; /** The priority of the message being sent. */ public const PRIORITY = 'priority'; /** An optional UNIX timestamp for your message. Otherwise the current time is used. */ public const TIMESTAMP = 'timestamp'; /** The sound to play on receiving the pushover message. */ public const SOUND = 'sound'; /** A number of seconds that the message will live, before being deleted automatically */ public const TTL = 'ttl'; }
Class: donatj\Pushover\Priority
Contains all legal values for 'priority'
<?php namespace donatj\Pushover; class Priority { public const LOWEST = -2; public const LOW = -1; public const NORMAL = 0; public const HIGH = 1; public const EMERGENCY = 2; }
Class: donatj\Pushover\Pushover
Dead Simple API Interface for Pushover Messages
<?php namespace donatj\Pushover; class Pushover { public const API_URL = 'https://api.pushover.net/1/messages.json'; }
Method: Pushover->__construct
function __construct(string $token, string $user [, string $apiUrl = self::API_URL])
Create a pushover object
Parameters:
- string
$token- The application API token - string
$user- Your user key - string
$apiUrl- Optionally change the API URL
Method: Pushover->send
function send(string $message [, array $options = []]) : array
Send the pushover message
Parameters:
- string
$message- The message to send - array<string,mixed>
$options- Optional configuration settings
Throws: \donatj\Pushover\Exceptions\ResponseException - On failure to connect or decode the response
Returns:
- array - The decoded JSON response as an associative array
Class: donatj\Pushover\Sounds
Contains legal values for 'sound'
<?php namespace donatj\Pushover; class Sounds { /** Pushover (default) */ public const PUSHOVER = 'pushover'; /** Bike */ public const BIKE = 'bike'; /** Bugle */ public const BUGLE = 'bugle'; /** Cash Register */ public const CASH_REGISTER = 'cashregister'; /** Classical */ public const CLASSICAL = 'classical'; /** Cosmic */ public const COSMIC = 'cosmic'; /** Falling */ public const FALLING = 'falling'; /** Gamelan */ public const GAMELAN = 'gamelan'; /** Incoming */ public const INCOMING = 'incoming'; /** Intermission */ public const INTERMISSION = 'intermission'; /** Magic */ public const MAGIC = 'magic'; /** Mechanical */ public const MECHANICAL = 'mechanical'; /** Piano Bar */ public const PIANO_BAR = 'pianobar'; /** Siren */ public const SIREN = 'siren'; /** Space Alarm */ public const SPACE_ALARM = 'spacealarm'; /** Tug Boat */ public const TUGBOAT = 'tugboat'; /** Alien Alarm (long) */ public const ALIEN = 'alien'; /** Climb (long) */ public const CLIMB = 'climb'; /** Persistent (long) */ public const PERSISTENT = 'persistent'; /** Pushover Echo (long) */ public const PUSHOVER_ECHO = 'echo'; /** Up Down (long) */ public const UP_DOWN = 'updown'; /** Vibrate Only */ public const VIBRATE = 'vibrate'; /** None (silent) */ public const NONE = 'none'; }
donatj/pushover 适用场景与选型建议
donatj/pushover 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40.19k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2013 年 06 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pushover」 「pushover.net」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 donatj/pushover 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 donatj/pushover 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 donatj/pushover 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Light, simple and fast, yet comprehensive wrapper for the Pushover API.
A simple wrapper for the Pushover.net API
A Yii2 PushOver log target and pushover messaging component
First-class Notifications for Craft CMS.
A simple, yet very powerful, package that helps you get started with sending push notifications to your iOS or Android device through the pushover.net service.
A symfony2 bundle for pushover
统计信息
- 总下载量: 40.19k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 28
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-06-18