webdevvie / pushover-bundle
一个用于Pushover的symfony2扩展包
0.3.1
2017-12-27 09:31 UTC
Requires
- php: >=5.3.0
- guzzle/guzzle: ~3.7
Requires (Dev)
- mockery/mockery: dev-master
- pdepend/pdepend: ~1.1
- phpmd/phpmd: ~1.5
- phpunit/phpunit: 3.7.*
- squizlabs/php_codesniffer: ~1.4
This package is auto-updated.
Last update: 2024-08-29 04:25:23 UTC
README
这是一个用于通过Pushover发送消息的简单symfony2扩展包。此库仍在开发中,其接口可能会更改。
待完成事项
- 检索收据状态
安装
使用composer添加
composer require "webdevvie/pushover-bundle"
将其添加到您的appkernel registerbundles方法中
new Webdevvie\PushoverBundle\WebdevviePushoverBundle(),
将您的令牌添加到配置中
webdevvie_pushover: token: %pushover_token%
将您的令牌添加到参数yaml文件中
pushover_token: "your_token_here"
要测试此功能
app/console pushover:send <usertoken>
按照以下步骤发送测试消息
在您的代码中
在您的应用程序中(在这种情况下是一个控制器)您可以使用以下代码向用户的pushover发送消息
# get the service from the container; $pushover = $this->get('pushover'); $message = new PushoverMessage(); $message->setUser("usercode_here"); $message->setSound("pushover"); $message->setTitle("A title here"); $message->setMessage("Your message here"); $response = $pushover->sendMessage($message); # Now you can check on the response object with $response->isSent(); # any errors are stored in the $response->getErrors() as an array of strings (isSent will then return false)
如果您想使用更高的优先级发送消息,您可以在消息对象上设置该属性,使用以PRIORITY_开始的常量
声音
所有声音都可通过PushoverMessage类的->availableSounds()
方法和以SOUND_开头的常量获取