Giter Site home page Giter Site logo

codeigniter4-pushover's Introduction

Tatter\Pushover

Pushover integration for CodeIgniter 4

Quick Start

  1. Install with Composer: > composer require tatter/pushover
  2. Add credentials to .env or Config/Pushover.php
  3. Send an alert: service('pushover')->message(['message' => 'Hello world'])->send();

Description

Tatter\Pushover adds an easy-to-use class for Pushover to your CodeIgniter 4 project. Send push notifications and access other API endpoints with the integrated Service and support entities.

Configuration (optional)

The library's default behavior can be altered by extending its config file. Copy examples/Pushover.php to app/Config/ and follow the instructions in the comments. If no config file is found in app/Config then the library will use its own.

In order to interface with Pushover you will need to specify your user secret and app token. As these are sensitive items it is highly recommended you supply them in your .env file instead of directly to repository code, e.g. (fake values):

pushover.user = e9e1495ec75826de5983cd1abc8031
pushover.token = KzGDORePKggMaC0QOYAMyEEuzJnyUi

Usage

Load the service with CodeIgniter's service helper:

$pushover = service('pushover');

Then craft your message and send it off to Pushover:

use Tatter\Pushover\Entities\Message;

$message = new Message([
	'title'    => 'My Message',
	'message'  => 'This is my first CodeIgniter push notification!',
	'priority' => 1,
]);

$pushover->sendMessage($message);

You may also use class convenience methods to draft Messages with pre-defined default properties (see examples/Pushover.php for configuration):

$message = $pushover->message(['message' => 'Hellow world']);
$message->send();

Troubleshooting

Follow Pushover's API specifications to make sure your messages are valid and you usage complies with their policies. Use the class method Pushover::getErrors() to access any error messages should something go wrong:

try
{
	$pushover->message(['title' => 'New Boots', 'attachment' => 'boots.jpg'])->send();
}
catch (\Tatter\Pushover\Exceptions\PushoverException $e)
{
	d($pushover->getErrors());
}
...
array (2) [
    0 => string (23) "message cannot be blank"
    1 => string (37) "The API returned a failing status: 0."
]

Development

Currently this module only supports the messages.json endpoint (including attachments), but more endpoints will be added in the future. If you have a specific request please open an issue (or PR!) for a new feature request.

codeigniter4-pushover's People

Contributors

mgatner avatar dependabot-preview[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.