nuccleon/pushover-http

pushover.net的PHP http get/post API

V1.3.0 2019-01-26 17:46 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:51:00 UTC


README

A simple HTTP api for the Pushover service. This is to make the service accessible for smaller (e.g. embedded) devices that does not support https.

使用composer安装

使用Composer进行安装。

将pushover-http添加到composer.json配置文件中。

$ composer require nuccleon/pushover-http

并更新composer

$ composer update

使用方法

配置

提供自己的pushover-http.ini.php文件以预设http参数。

cat pushover-http-config.ini.php.template > pushover-http-config.ini.php

HTTP API

通过GET或POST传递参数,至少包括用户、令牌和优先级。

详见Pushover-API获取详细参数说明。

'job'       =>  $mandatory, // Job selector. 'push', 'poll' or 'cancel' allowed.
'user'      =>  $mandatory, // the user/group key (not e-mail address) of your user (or you), viewable
                            // when logged into our dashboard (often referred to as USER_KEY in our
                            // documentation and code examples)
'token'     =>  $mandatory, // your application's API token
'message'   =>  $mandatory, // your message
'priority'  =>  $optional,  // send as -2 to generate no notification/alert, -1 to always send as a quiet
                            // notification, 1 to display as high-priority and bypass the user's quiet hours,
                            // or 2 to also require confirmation from the user
'attachment =>  $optional,  // An image attachment to send with the message (could be either a path to the image or an URL to download the image from)                            
'device'    =>  $optional,  // your user's device name to send the message directly to that device,
                            // rather than all of the user's devices (multiple devices may be separated by a comma)
'title'     =>  $optional,  // your message's title, otherwise your app's name is used
'url'       =>  $optional,  // a supplementary URL to show with your message
'urlTitle'  =>  $optional,  // a title for your supplementary URL, otherwise just the URL is shown
'sound'     =>  $optional,  // The name of one of the sounds supported by device clients to override the user's default sound choice
'html'      =>  $optional,  // To enable HTML formatting. The normal message content in your message parameter will then be displayed as HTML. 
'date'      =>  $optional,  // a Unix timestamp of your message's date and time to display to the user, rather than the time your message is received by our API
                            // has to be formated as defined in DATE_FORMAT
'retry'     =>  $optional,  // Specifies how often (in seconds) the Pushover servers will send the same notification to the user (EMERGENCY only, mandatory for EMERGENCY)
'expire'    =>  $optional,  // The expire parameter specifies how many seconds your notification will continue to be retried (EMERGENCY only, mandatory for EMERGENCY)
'callback'  =>  $optional,  // The optional callback parameter may be supplied with a publicly-accessible URL that our servers will send a request to when the user has acknowledged your notification.
'receipt'   =>  $mandatory, // This receipt can be used to periodically poll the receipts API to get the status of your notification
'echo'      =>  $optional   // set this to redirect debug logs to the http response (GET only)
'config'    =>  $optional   // The configuration group within the ini-file that should be used

使用wget和GET的基本示例

wget "localhost/pushover-http/pushover-http.php/?job=push&user=foo&token=bar&message=baz&config=my

调试

pushover-http.php?echo添加到查询中,将日志输出重定向到http响应而不是日志文件