diff --git a/Pushover.php b/Pushover.php index ff342bd..1ec149b 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 getSoundsList() + { + $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..c229150 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 + +* getSoundsList +> Downloads from API Pushover sound list \ No newline at end of file