leonardoteixeira/pushover
最新稳定版本:v1.2
Composer 安装命令:
composer require leonardoteixeira/pushover
包简介
A simple PHP library for the Pushover service
README 文档
README
A simple PHP library for the Pushover service.
This library was written using the PSR-4 standards.
Installation
Use the Composer to install.
composer.json
{
"require": {
"leonardoteixeira/pushover": "1.*"
}
}
Running the composer
composer install
Usage
Basic Example
<?php require 'vendor/autoload.php'; use LeonardoTeixeira\Pushover\Client; use LeonardoTeixeira\Pushover\Message; use LeonardoTeixeira\Pushover\Exceptions\PushoverException; $client = new Client('YOUR_USER_CODE_HERE', 'YOUR_TOKEN_HERE'); $message = new Message('Your message here.'); try { $client->push($message); echo 'The message has been pushed!', PHP_EOL; } catch (PushoverException $e) { echo 'ERROR: ', $e->getMessage(), PHP_EOL; }
You also can pass a title and the priority on constructor:
$message = new Message('Your message here.', 'Title here', Priority::HIGH);
Complete Example
<?php require 'vendor/autoload.php'; date_default_timezone_set('UTC'); use LeonardoTeixeira\Pushover\Client; use LeonardoTeixeira\Pushover\Message; use LeonardoTeixeira\Pushover\Priority; use LeonardoTeixeira\Pushover\Sound; use LeonardoTeixeira\Pushover\Exceptions\PushoverException; use LeonardoTeixeira\Pushover\Receipt; use LeonardoTeixeira\Pushover\Status; $client = new Client('YOUR_USER_CODE_HERE', 'YOUR_TOKEN_HERE'); $message = new Message(); $message->setMessage('Your messsage <b>here</b>.'); $message->setTitle('Title here'); $message->setUrl('http://www.example.com/'); $message->setAttachment('pic.jpg'); $message->setUrlTitle('Click me!'); $message->setPriority(Priority::HIGH); $message->setSound(Sound::SIREN); $message->setHtml(true); $message->setDate(new \DateTime()); try { $receipt = $client->push($message); echo 'The message has been pushed!', PHP_EOL; $status = $client->poll($receipt); } catch (PushoverException $e) { echo 'ERROR: ', $e->getMessage(), PHP_EOL; }
Emergency Priority
For the emergency priority you must provide the parameters retry and expire. The callback parameter is optional.
$message->setPriority(Priority::EMERGENCY); $message->setRetry(60); $message->setExpire(10800); $message->setCallback('http://callback-url.com/');
You can poll the notification status using poll.
Running the tests
vendor/bin/phpunit
统计信息
- 总下载量: 27.56k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 0
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-08-18