2017 © Pedro Peláez
 

library pushnotifier-php

PushNotifier library for PHP

image

gidix/pushnotifier-php

PushNotifier library for PHP

  • Tuesday, January 2, 2018
  • by bluefirex
  • Repository
  • 2 Watchers
  • 3 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 117 % Grown

The README.md

PushNotifier (v2) for PHP

A pretty convenient library to use PushNotifier in PHP projects., (*1)

Installation

Add this to composer.json:, (*2)

"require": {
    "gidix/pushnotifier-php": "^2.0.0"
}

...or run composer require gidix/pushnotifier-php, (*3)

Usage

You only have to use one class: GIDIX\PushNotifier\SDK\PushNotifier. Everything is derived from there., (*4)

Creating your Application

Before you can actually do anything, you have to create your application. It consists of an API Token and a package name. Both can be configured at pushnotifier.de/account/api., (*5)

Then you can create your instance:, (*6)

    $app = new GIDIX\PushNotifier\SDK\PushNotifier([
        'api_token'     =>  'YOUR_API_TOKEN',
        'package'       =>  'YOUR.PACKAGE.NAME'
    ]);

Login

When authenticating as a user you have to log them in, then use their AppToken for all further communication:, (*7)

    $appToken = $app->login('username', 'password');

You can store $appToken anywhere you like by converting it to a string before storing (see examples/storing-app-token.php)., (*8)

Afterwards you can use the AppToken to authenticate:, (*9)

    $app = new GIDIX\PushNotifier\SDK\PushNotifier([
        'api_token'     =>  'YOUR_API_TOKEN',
        'package'       =>  'YOUR.PACKAGE.NAME',
        'app_token'     =>  $appToken
    ]);

Retrieving Devices

    $devices = $app->getDevices();

will retrieve an array of GIDIX\PushNotifier\SDK\Device objects, containing an ID, a title, a model and a link to an image of the device. Device IDs do not change over time and serve as a unique identifier., (*10)

Sending Texts

    $result = $app->sendMessage($devices, 'Some Content');

$devices has to be an array of either Device objecs or device ID strings, i.e. ['abc', 'xyz']., (*11)

Sending URLs

    $result = $app->sendURL($devices, 'https://some.example.org/with/path.html');

$devices has to be an array of either Device objecs or device ID strings, i.e. ['abc', 'xyz']., (*12)

Sending Notifications

    $result = $app->sendNotification($devices, 'Some Content', 'https://some.example.org/with/path.html');

Exceptions

  • DeviceNotFoundException: When a device couldn't be found
  • InvalidAPITokenException: When the api_token or package couldn't be verified
  • InvalidAppTokenException: When the AppToken couldn't be verified or has expired
  • InvalidCredentialsException: When login credentials were incorrect
  • InvalidRequestException: When some request data was malformatted, i.e. malformatted URL for notifications
  • PushNotifierException: Base Exception for all these, only thrown in case of an unknown error (500)

$devices has to be an array of either Device objecs or device ID strings, i.e. ['abc', 'xyz']., (*13)

Examples

Examples can be found in examples/ of this repository., (*14)

The Versions

02/01 2018

dev-master

9999999-dev

PushNotifier library for PHP

  Sources   Download

proprietary

The Requires

 

The Development Requires

02/01 2018

2.0

2.0.0.0

PushNotifier library for PHP

  Sources   Download

proprietary

The Requires

 

The Development Requires