https://github.com/donatj/pushover-php
Simple Pushover API Wrapper for PHP
https://github.com/donatj/pushover-php
api-wrapper pushover-api pushover-php
Last synced: 11 months ago
JSON representation
Simple Pushover API Wrapper for PHP
- Host: GitHub
- URL: https://github.com/donatj/pushover-php
- Owner: donatj
- License: mit
- Created: 2013-02-27T17:58:46.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2024-11-30T04:15:40.000Z (over 1 year ago)
- Last Synced: 2025-03-29T23:11:51.625Z (11 months ago)
- Topics: api-wrapper, pushover-api, pushover-php
- Language: PHP
- Homepage:
- Size: 90.8 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Pushover PHP
[](https://packagist.org/packages/donatj/pushover)
[](https://packagist.org/packages/donatj/pushover)
[](https://packagist.org/packages/donatj/pushover)
[](https://github.com/donatj/Pushover-PHP/actions/workflows/ci.yml)
Pushover PHP is a very light, simple API wrapper for the Pushover API written for PHP.
## Requirements
- **php**: >=7.3
- **ext-json**: *
## Installing
Install the latest version with:
```bash
composer require 'donatj/pushover'
```
## Usage
```php
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](https://pushover.net/api).
On *success* `Pushover->send` returns a **truth-y** array like:
```php
[
'status' => '1',
'request' => '2f4e9c7140df52d7d8b16ffb8adf1c2a',
]
```
On *failure* `Pushover->send` returns **false** which allows simple
```php
if( !$po->send('Hello World!') ) {
die('oh no!');
}
```
### Class: \donatj\Pushover\Exceptions\ResponseException
```php
__construct
```php
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
```php
function send(string $message [, array $options = []]) : array
```
Send the pushover message
##### Parameters:
- ***string*** `$message` - The message to send
- ***array*** `$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