From c56bb508ea00c19a21d4f39505bcc830bdde63a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Dvo=C5=99=C3=A1k?= Date: Sat, 21 May 2016 21:56:20 +0200 Subject: [PATCH 1/2] Added method getSounds for downloading audio recording from the API --- Pushover.php | 25 ++++++++++++++++++++++++- README.md | 5 ++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Pushover.php b/Pushover.php index ff342bd..7302af7 100644 --- a/Pushover.php +++ b/Pushover.php @@ -5,7 +5,7 @@ * PHP service wrapper for the pushover.net API: https://pushover.net/api * * @author Chris Schalenborgh - * @version 0.2 + * @version 0.3 * @package php-pushover * @example test.php * @link https://pushover.net/api @@ -16,6 +16,7 @@ class Pushover { // api url const API_URL = 'https://api.pushover.net/1/messages.xml'; + const SOUNDS_API_URL = 'https://api.pushover.net/1/sounds.json'; /** * Application API token @@ -446,5 +447,27 @@ public function send() { } } } + + /** + * Downloads from API Pushover sound list + * + * @return array|bool + */ + public function getSounds() + { + $c = curl_init(); + curl_setopt($c, CURLOPT_URL, self::SOUNDS_API_URL . '?token=' . $this->getToken()); + curl_setopt($c, CURLOPT_HEADER, false); + curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($c); + $sounds = json_decode($response); + + if ($this->getDebug()) { + return array('output' => $response, 'input' => $this); + } else { + return ($sounds->status == 1) ? $sounds->sounds : false; + } + } } ?> diff --git a/README.md b/README.md index bf76179..6c6f228 100644 --- a/README.md +++ b/README.md @@ -46,4 +46,7 @@ > Enable this to receive detailed input and output info. * send -> Send the message to the API \ No newline at end of file +> Send the message to the API + +* getSounds +> Downloads from API Pushover sound list \ No newline at end of file From a939f8746a235cef7e4ab5fba941b04f9aa56af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Dvo=C5=99=C3=A1k?= Date: Sun, 22 May 2016 13:42:05 +0200 Subject: [PATCH 2/2] Added method getSounds for downloading audio recording from the API --- Pushover.php | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Pushover.php b/Pushover.php index 7302af7..1ec149b 100644 --- a/Pushover.php +++ b/Pushover.php @@ -453,7 +453,7 @@ public function send() { * * @return array|bool */ - public function getSounds() + public function getSoundsList() { $c = curl_init(); curl_setopt($c, CURLOPT_URL, self::SOUNDS_API_URL . '?token=' . $this->getToken()); diff --git a/README.md b/README.md index 6c6f228..c229150 100644 --- a/README.md +++ b/README.md @@ -48,5 +48,5 @@ * send > Send the message to the API -* getSounds +* getSoundsList > Downloads from API Pushover sound list \ No newline at end of file