An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# Pushover PHP

[![Latest Stable Version](https://poser.pugx.org/donatj/pushover/version)](https://packagist.org/packages/donatj/pushover)
[![Total Downloads](https://poser.pugx.org/donatj/pushover/downloads)](https://packagist.org/packages/donatj/pushover)
[![License](https://poser.pugx.org/donatj/pushover/license)](https://packagist.org/packages/donatj/pushover)
[![ci.yml](https://github.com/donatj/Pushover-PHP/actions/workflows/ci.yml/badge.svg)](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