2017 © Pedro Peláez
 

library pushover

A simple PHP library for the Pushover service

image

leonardoteixeira/pushover

A simple PHP library for the Pushover service

  • Thursday, January 25, 2018
  • by LeonardoTeixeira
  • Repository
  • 5 Watchers
  • 10 Stars
  • 6,443 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 4 Versions
  • 15 % Grown

The README.md

Pushover for PHP

Build Status Version Total Downloads License, (*1)

A simple PHP library for the Pushover service., (*2)

This library was written using the PSR-4 standards., (*3)

Installation

Use the Composer to install., (*4)

composer.json

{
    "require": {
        "leonardoteixeira/pushover": "1.*"
    }
}

Running the composer

composer install

Usage

Basic Example

<?php

require 'vendor/autoload.php';

use LeonardoTeixeira\Pushover\Client;
use LeonardoTeixeira\Pushover\Message;
use LeonardoTeixeira\Pushover\Exceptions\PushoverException;

$client = new Client('YOUR_USER_CODE_HERE', 'YOUR_TOKEN_HERE');

$message = new Message('Your message here.');

try {
    $client->push($message);
    echo 'The message has been pushed!', PHP_EOL;
} catch (PushoverException $e) {
    echo 'ERROR: ', $e->getMessage(), PHP_EOL;
}

You also can pass a title and the priority on constructor:, (*5)

$message = new Message('Your message here.', 'Title here', Priority::HIGH);

Complete Example

<?php

require 'vendor/autoload.php';

date_default_timezone_set('UTC');

use LeonardoTeixeira\Pushover\Client;
use LeonardoTeixeira\Pushover\Message;
use LeonardoTeixeira\Pushover\Priority;
use LeonardoTeixeira\Pushover\Sound;
use LeonardoTeixeira\Pushover\Exceptions\PushoverException;
use LeonardoTeixeira\Pushover\Receipt;
use LeonardoTeixeira\Pushover\Status;

$client = new Client('YOUR_USER_CODE_HERE', 'YOUR_TOKEN_HERE');

$message = new Message();
$message->setMessage('Your messsage <b>here</b>.');
$message->setTitle('Title here');
$message->setUrl('http://www.example.com/');
$message->setAttachment('pic.jpg');
$message->setUrlTitle('Click me!');
$message->setPriority(Priority::HIGH);
$message->setSound(Sound::SIREN);
$message->setHtml(true);
$message->setDate(new \DateTime());

try {
    $receipt = $client->push($message);
    echo 'The message has been pushed!', PHP_EOL;
    $status = $client->poll($receipt);
} catch (PushoverException $e) {
    echo 'ERROR: ', $e->getMessage(), PHP_EOL;
}

Emergency Priority

For the emergency priority you must provide the parameters retry and expire. The callback parameter is optional., (*6)

More information, (*7)

$message->setPriority(Priority::EMERGENCY);
$message->setRetry(60);
$message->setExpire(10800);
$message->setCallback('http://callback-url.com/');

You can poll the notification status using poll., (*8)

Running the tests

vendor/bin/phpunit

The Versions

25/01 2018

dev-master

9999999-dev https://github.com/LeonardoTeixeira/pushover

A simple PHP library for the Pushover service

  Sources   Download

MIT

The Requires

 

The Development Requires

by Leonardo Cesar Teixeira

api notification ios push android mobile iphone tablet pushover ipad

20/01 2017

v1.2

1.2.0.0 https://github.com/LeonardoTeixeira/pushover

A simple PHP library for the Pushover service

  Sources   Download

MIT

The Requires

 

The Development Requires

by Leonardo Cesar Teixeira

api notification ios push android mobile iphone tablet pushover ipad

04/01 2016

v1.1

1.1.0.0 https://github.com/LeonardoTeixeira/pushover

A simple PHP library for the Pushover service

  Sources   Download

MIT

The Requires

 

The Development Requires

by Leonardo Cesar Teixeira

api notification ios push android mobile iphone tablet pushover ipad

02/06 2015

v1.0

1.0.0.0 https://github.com/LeonardoTeixeira/pushover

A simple PHP library for the Pushover service

  Sources   Download

MIT

The Requires

 

The Development Requires

by Leonardo Cesar Teixeira

api notification ios push android mobile iphone tablet pushover ipad