├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── composer.json ├── phpunit.xml └── src ├── Dyaa └── Pushover │ ├── Commands │ └── PushoverCommand.php │ ├── Facades │ └── Pushover.php │ ├── Pushover.php │ └── PushoverServiceProvider.php └── config ├── .gitkeep └── config.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.phar 3 | composer.lock 4 | .DS_Store 5 | .idea/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.4 5 | - 5.5 6 | 7 | before_script: 8 | - curl -s http://getcomposer.org/installer | php 9 | - php composer.phar install --dev 10 | 11 | script: phpunit -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Dyaa Eldin Moustafa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Laravel 5 Pushover.net Package 2 | ====== 3 | [![Build Status](https://travis-ci.org/dyaa/Laravel-pushover.svg?branch=v1.4.0)](https://travis-ci.org/dyaa/Laravel-pushover) [![Latest Stable Version](https://poser.pugx.org/dyaa/pushover/v/stable.png)](https://packagist.org/packages/dyaa/pushover) [![Total Downloads](https://poser.pugx.org/dyaa/pushover/downloads.png)](https://packagist.org/packages/dyaa/pushover) [![Latest Unstable Version](https://poser.pugx.org/dyaa/pushover/v/unstable.png)](https://packagist.org/packages/dyaa/pushover) [![Dependency Status](https://www.versioneye.com/user/projects/5303cf06ec1375065e000003/badge.png)](https://www.versioneye.com/user/projects/5303cf06ec1375065e000003) [![License](https://poser.pugx.org/dyaa/pushover/license.png)](https://packagist.org/packages/dyaa/pushover) 4 | 5 | A Laravel 5 package for Android and iOS push notification service from https://pushover.net/. 6 | 7 | **Please if you found any bug or you have any enhancement, You're so welcomed to open an Issue or make a pull request. 8 | 9 | #### Content 10 | - [Installation](#installation) 11 | - [Configuration](#configuration) 12 | - [Usage](#usage) 13 | - [Commands](#commands) 14 | - [License](#license) 15 | 16 | ---------- 17 | 18 | 19 | #### Installation 20 | If you still using laravel 4.1 use the **1.3.0** version 21 | 22 | To get the latest version of dyaa/pushover simply require it in your `composer.json` file. 23 | 24 | ```js 25 | "dyaa/pushover": "dev-master" 26 | ``` 27 | 28 | After that, you'll need to run `composer update` to download the latest Version and updating the autoloader. 29 | 30 | Or 31 | 32 | ```bash 33 | composer require dyaa/pushover:dev-master 34 | ``` 35 | 36 | 37 | 38 | Once dyaa/pushover is installed, you need to register the Service Provider. To do that open `app/config/app.php` and add the following to the `providers` key. 39 | 40 | ```php 41 | 'Dyaa\Pushover\PushoverServiceProvider', 42 | ``` 43 | 44 | Next you add this facade to `app/config/app.php` 45 | 46 | ```php 47 | 'Dyaa\Pushover\Facades\Pushover', 48 | ``` 49 | 50 | To use this in your L5 application: 51 | 52 | ```php 53 | use Dyaa\Pushover\Facades\Pushover; 54 | ``` 55 | 56 | ---------- 57 | 58 | 59 | #### Configuration 60 | 61 | Create `app/config/pushover.php` and fill it with your Token and the User Key from https://pushover.net/ 62 | 63 | ```php 64 | return [ 65 | 'token' => 'App Token', 66 | 'user_key' => 'User Key', 67 | ]; 68 | ``` 69 | 70 | ---------- 71 | 72 | #### Usage 73 | Now you can use the package like that: 74 | 75 | To Set a message (**Required**) 76 | ```php 77 | Pushover::push($title, $message); 78 | ``` 79 | To Set a Link (Optional) 80 | ```php 81 | Pushover::url($url, $title); 82 | ``` 83 | To Set a Callback (Optional) 84 | ```php 85 | Pushover::callback($callbackURL); 86 | ``` 87 | To Set a Sound (Optional) Supported Notification Sounds https://pushover.net/api#sounds 88 | ```php 89 | Pushover::sound($sound); 90 | ``` 91 | To Set a Device Name (Optional) 92 | ```php 93 | Pushover::device($device); 94 | ``` 95 | To Set if the Message should be sent as HTML (Optional) Default is 1 96 | ```php 97 | Pushover::html($html); 98 | ``` 99 | To Set a Timestamp (Optional) Default is *time()* 100 | ```php 101 | Pushover::timestamp($timestamp); 102 | ``` 103 | To Set Priority (Optional) For More Info about Priority https://pushover.net/api#priority 104 | ```php 105 | Pushover::priority($priority, $retry, $expire); 106 | ``` 107 | To turn the Debug mode (Optional) 108 | ```php 109 | Pushover::debug(true); 110 | ``` 111 | To Send the Message (**Required**) 112 | ```php 113 | Pushover::send(); 114 | ``` 115 | All other information will be found in details here https://pushover.net/api 116 | 117 | 118 | ---------- 119 | #### Commands 120 | 121 | In the version 1.2.0 and above it supports the Artisan Commands but first make sure that you've done the [Configuration](#configuration) correctly. 122 | 123 | You can run 124 | 125 | php artisan list 126 | and you'll find 127 | 128 | pushover 129 | pushover:send Pushover Command 130 | 131 | To send a pushover message you'll be able to use it like this way ( **Title and Message are Required** ) 132 | 133 | php artisan pushover:send YourTitle YourMessage 134 | to turn on the debug mode just add 135 | 136 | --debug 137 | in the end of the Command line 138 | 139 | to set a sound you can add *"Optional"* 140 | 141 | --sound=YourSound 142 | 143 | To know the supported sounds from here https://pushover.net/api#sounds 144 | 145 | to set a Device name *"Optional"* 146 | 147 | --device=YourDeviceName 148 | 149 | to send a URL *"Optional"* 150 | 151 | --url=http://www.example.com/ 152 | 153 | to set a title for the URL *"Optional"* 154 | 155 | --urltitle=UrlTitle 156 | 157 | to set a priority Message you can know more about the Priority Messages from here https://pushover.net/api#priority *"Optional"* 158 | 159 | --priority=1 160 | 161 | to set a priority retry *(in seconds)* Default is **60** *"Optional"* 162 | 163 | --retry=60 164 | 165 | to set a priority expire *(in seconds)* Default is **356** *"Optional"* 166 | 167 | --expire=356 168 | 169 | to set if message should be sent as HTML. Default is **1** *"Optional"* 170 | *Note: Message body needs to be wrapped in quotes.* 171 | 172 | --html=1 173 | 174 | ---------- 175 | 176 | 177 | #### License 178 | 179 | Copyright (c) 2017 [Dyaa Eldin Moustafa][1] Licensed under the [MIT license][2]. 180 | 181 | 182 | [1]: https://dyaa.me/ 183 | [2]: https://github.com/dyaa/Laravel-pushover/blob/master/LICENSE 184 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dyaa/pushover", 3 | "description": "Laravel 5 Pushover Package", 4 | "keywords": ["laravel", "pushover", "Real Time", "notification","Artisan","CLI","Command"], 5 | "license": "MIT", 6 | "version": "1.4.1", 7 | "type": "laravel-package", 8 | "authors": [ 9 | { 10 | "name": "Dyaa Eldin", 11 | "email": "mail@dyaa.me", 12 | "homepage": "http://www.dyaa.me/" 13 | } 14 | ], 15 | "require": { 16 | "php": ">=5.4.0", 17 | "illuminate/support": "~5.0" 18 | }, 19 | "autoload": { 20 | "psr-0": { 21 | "Dyaa\\Pushover\\": "src/" 22 | } 23 | }, 24 | "minimum-stability": "stable" 25 | } 26 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | ./tests/ 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Dyaa/Pushover/Commands/PushoverCommand.php: -------------------------------------------------------------------------------- 1 | push = $push; 32 | } 33 | 34 | /** 35 | * Execute the console command. 36 | * 37 | * @return mixed 38 | */ 39 | public function fire() 40 | { 41 | $title = $this->argument('title'); 42 | $msg = $this->argument('msg'); 43 | $url = $this->option('url'); 44 | $urltitle = $this->option('urltitle'); 45 | $debug = $this->option('debug'); 46 | $sound = $this->option('sound'); 47 | $device = $this->option('device'); 48 | $priority = $this->option('priority'); 49 | $retry = $this->option('retry'); 50 | $expire = $this->option('expire'); 51 | $html = $this->option('html'); 52 | 53 | if (!isset($retry)) { 54 | $retry = 60; 55 | } 56 | 57 | if (!isset($expire)) { 58 | $expire = 365; 59 | } 60 | 61 | if(!isset($html)) { 62 | $html = 1; 63 | } 64 | 65 | if (!isset($urltitle)) { 66 | $urltitle = $url; 67 | } 68 | 69 | // Check if Debug mode is turned on 70 | if ($debug) { 71 | $this->push->debug(true); 72 | } 73 | 74 | // if sound var is set 75 | if ($sound) { 76 | $this->push->sound($sound); 77 | } 78 | 79 | if ($html) { 80 | $this->push->html($html); 81 | } 82 | // if device var is set 83 | if ($device) { 84 | $this->push->device($device); 85 | } 86 | 87 | // if url var is set 88 | if ($url) { 89 | $this->push->url($url, $urltitle); 90 | } 91 | 92 | // if priority var is set 93 | if ($priority) { 94 | $this->push->priority($priority, $retry, $expire); 95 | } 96 | 97 | $this->push->push($title, $msg); 98 | 99 | if ($debug) { 100 | $this->info($this->push->send()); 101 | } else if ($this->push->send()) { 102 | $this->info("Your message has been sent."); 103 | } else { 104 | $this->error('Something went wrong!'); 105 | } 106 | } 107 | 108 | /** 109 | * Get the console command arguments. 110 | * 111 | * @return array 112 | */ 113 | protected function getArguments() 114 | { 115 | return [ 116 | ['title', InputArgument::REQUIRED, 'Title argument.'], 117 | ['msg', InputArgument::REQUIRED, 'Message argument.'], 118 | ]; 119 | } 120 | 121 | /** 122 | * Get the console command options. 123 | * 124 | * @return array 125 | */ 126 | protected function getOptions() 127 | { 128 | return [ 129 | ['url', null, InputOption::VALUE_OPTIONAL, 'URL to send.', null], 130 | ['urltitle', null, InputOption::VALUE_OPTIONAL, 'URL Title to send.', null], 131 | ['sound', null, InputOption::VALUE_OPTIONAL, 'Set notification Sound.', null], 132 | ['device', null, InputOption::VALUE_OPTIONAL, 'Set a Device.', null], 133 | ['priority', null, InputOption::VALUE_OPTIONAL, 'Set a Priority Message.', null], 134 | ['retry', null, InputOption::VALUE_OPTIONAL, 'Set a Retry for the Priority.', null], 135 | ['expire', null, InputOption::VALUE_OPTIONAL, 'Set an expire for the Priority.', null], 136 | ['html', null, InputOption::VALUE_OPTIONAL, 'Sets if message should be sent as HTML.', null], 137 | ['debug', null, InputOption::VALUE_NONE, 'Turn the Debug Mode.', null], 138 | ]; 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /src/Dyaa/Pushover/Facades/Pushover.php: -------------------------------------------------------------------------------- 1 | config = $config; 29 | $this->token = $this->config->get('pushover.token'); 30 | $this->user_key = $this->config->get('pushover.user_key'); 31 | } 32 | 33 | public function config($token, $user_key) 34 | { 35 | // in case you want to dynamically update the token/user key 36 | $this->token = $token; 37 | $this->user_key = $user_key; 38 | } 39 | 40 | public function push($title, $msg) 41 | { 42 | $this->title = $title; 43 | $this->msg = $msg; 44 | } 45 | 46 | public function url($url, $title) 47 | { 48 | $this->urlTitle = $title; 49 | $this->url = $url; 50 | } 51 | 52 | public function callback($callback) 53 | { 54 | $this->callback = $callback; 55 | } 56 | 57 | public function sound($sound) 58 | { 59 | $this->sound = $sound; 60 | } 61 | 62 | public function debug($debug = null) 63 | { 64 | if ($debug == null) { 65 | $this->debug = false; 66 | } else { 67 | $this->debug = $debug; 68 | } 69 | } 70 | 71 | public function device($device) 72 | { 73 | $this->device = $device; 74 | } 75 | 76 | public function html($html) 77 | { 78 | $this->html = $html; 79 | } 80 | 81 | public function timestamp($timestamp = null) 82 | { 83 | if ($timestamp == null) { 84 | $timestamp = time(); 85 | } 86 | $this->timestamp = $timestamp; 87 | } 88 | 89 | public function priority($priority = 0, $retry = 60, $expire = 365) 90 | { 91 | $this->priority = $priority; 92 | $this->retry = $retry; 93 | $this->expire = $expire; 94 | } 95 | 96 | public function user($user_key) 97 | { 98 | $this->user_key = $user_key; 99 | } 100 | 101 | public function send() 102 | { 103 | $c = curl_init(); 104 | curl_setopt($c, CURLOPT_URL, self::API_URL); 105 | curl_setopt($c, CURLOPT_HEADER, false); 106 | curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false); 107 | curl_setopt($c, CURLOPT_RETURNTRANSFER, true); 108 | curl_setopt($c, CURLOPT_POSTFIELDS, array( 109 | 'token' => $this->token, 110 | 'user' => $this->user_key, 111 | 'title' => $this->title, 112 | 'message' => $this->msg, 113 | 'device' => $this->device, 114 | 'timestamp' => $this->timestamp, 115 | 'html' => $this->html, 116 | 'callback' => $this->callback, 117 | 'sound' => $this->sound, 118 | 'url' => $this->url, 119 | 'url_title' => $this->urlTitle, 120 | 'priority' => $this->priority, 121 | 'retry' => $this->retry, 122 | 'expire' => $this->expire 123 | )); 124 | 125 | $response = curl_exec($c); 126 | 127 | if ($this->debug) { 128 | return $response; 129 | } else { 130 | $response = json_decode($response); 131 | return $response->status; 132 | } 133 | } 134 | 135 | } 136 | -------------------------------------------------------------------------------- /src/Dyaa/Pushover/PushoverServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->singleton('pushover', function($app) 24 | { 25 | return new Pushover($app['config']); 26 | }); 27 | 28 | $this->app->booting(function() 29 | { 30 | $loader = AliasLoader::getInstance(); 31 | $loader->alias('Pushover', 'Dyaa\Pushover\Facades\Pushover'); 32 | }); 33 | 34 | $this->app->singleton('pushover.send', function () 35 | { 36 | return new Commands\PushoverCommand($this->app['pushover']); 37 | }); 38 | 39 | $this->commands( 40 | 'pushover.send' 41 | ); 42 | } 43 | 44 | /** 45 | * Get the services provided by the provider. 46 | * 47 | * @return array 48 | */ 49 | public function provides() 50 | { 51 | return ['pushover']; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/config/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyaa/Laravel-pushover/aff8c8c151f2f772b28f01bf1226a9359e46dab9/src/config/.gitkeep -------------------------------------------------------------------------------- /src/config/config.php: -------------------------------------------------------------------------------- 1 | 'App Token', 6 | 'user_key' => 'User Key', 7 | 8 | ); --------------------------------------------------------------------------------