daltcore / pushover
Laravel 5 Pushover 包
Requires
- php: >=5.4.0
- illuminate/support: ~5.0
README
这是一个用于https://pushover.net/提供的Android和iOS推送通知服务的Laravel 5包。
**如果您发现了任何错误或有任何增强建议,请随时创建一个问题或发起一个Pull Request。
内容
安装
如果您仍在使用laravel 4.1,请使用 1.3.0 版本。
要获取dyaa/pushover的最新版本,只需在您的 composer.json
文件中包含它。
"dyaa/pushover": "dev-master"
之后,您需要运行 composer update
来下载最新版本并更新自动加载器。
或者
composer require dyaa/pushover:dev-master
安装dyaa/pushover后,您需要注册服务提供者。要做到这一点,请打开 app/config/app.php
并将以下内容添加到 providers
键。
'Dyaa\Pushover\PushoverServiceProvider',
接下来,将此外观添加到 app/config/app.php
'Dyaa\Pushover\Facades\Pushover',
要在您的L5应用中使用此功能
use Dyaa\Pushover\Facades\Pushover;
配置
创建 app/config/pushover.php
并用您的Token和从https://pushover.net/获取的用户密钥填充它。
return [ 'token' => 'App Token', 'user_key' => 'User Key', ];
用法
现在您可以使用该包,如下所示
设置消息(必需)
Pushover::push($title, $message);
设置链接(可选)
Pushover::url($url, $title);
设置回调(可选)
Pushover::callback($callbackURL);
设置声音(可选)支持的通知声音 https://pushover.net/api#sounds
Pushover::sound($sound);
设置设备名称(可选)
Pushover::device($device);
设置消息是否应作为HTML发送(可选)默认为1
Pushover::html($html);
设置时间戳(可选)默认为 time()
Pushover::timestamp($timestamp);
设置优先级(可选)有关优先级的更多信息 https://pushover.net/api#priority
Pushover::priority($priority, $retry, $expire);
开启调试模式(可选)
Pushover::debug(true);
发送消息(必需)
Pushover::send();
所有其他信息可以在这里找到 https://pushover.net/api
命令
版本1.2.0及以上支持Artisan命令,但首先请确保您已经正确完成了配置。
您可以运行
php artisan list
然后您会发现
pushover
pushover:send Pushover Command
要发送Pushover消息,您可以使用这种方式( 标题和消息是必需的 )
php artisan pushover:send YourTitle YourMessage
要开启调试模式,只需在命令行末尾添加
--debug
要设置声音,可以添加 "可选"
--sound=YourSound
要了解支持的声音,请从这里https://pushover.net/api#sounds
要设置设备名称 "可选"
--device=YourDeviceName
要发送URL "可选"
--url=http://www.example.com/
要为URL设置标题 "可选"
--urltitle=UrlTitle
要设置优先级消息,您可以在这里了解更多关于优先级消息的信息 https://pushover.net/api#priority "可选"
--priority=1
设置优先级重试时间(秒)(可选) 默认为 60 “可选”
--retry=60
设置优先级过期时间(秒)(可选) 默认为 356 “可选”
--expire=356
设置是否以HTML格式发送消息。默认为 1 “可选” 注意:消息正文需要用引号括起来。
--html=1
许可协议
版权所有(c)2017 Dyaa Eldin Moustafa 许可协议:MIT。