diff options
author | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2019-11-25 08:22:35 +0000 |
---|---|---|
committer | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2019-11-25 08:22:35 +0000 |
commit | c61784411988d36d9bbd93cd3a97e773990af342 (patch) | |
tree | 924e6e9dea2ba7b1eedb14d0c4b03a38aefdf179 /Postman/notifications/PostmanPushoverNotify.php | |
parent | 907ce8c044159ca8da6ccce3ec5362ac61e7c142 (diff) | |
download | Post-SMTP-c61784411988d36d9bbd93cd3a97e773990af342.zip |
Adding a folder
Diffstat (limited to 'Postman/notifications/PostmanPushoverNotify.php')
-rw-r--r-- | Postman/notifications/PostmanPushoverNotify.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Postman/notifications/PostmanPushoverNotify.php b/Postman/notifications/PostmanPushoverNotify.php new file mode 100644 index 0000000..14ef7d2 --- /dev/null +++ b/Postman/notifications/PostmanPushoverNotify.php @@ -0,0 +1,34 @@ +<?php +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly +} +class PostmanPushoverNotify implements Postman_Notify { + + public function send_message($message) + { + $options = PostmanOptions::getInstance(); + + $api_url = "https://api.pushover.net/1/messages.json"; + $app_token = $options->getPushoverToken(); + $user_key = $options->getPushoverUser(); + + $args = array( + 'body' => array( + "token" => $app_token, + "user" => $user_key, + "message" => $message, + ) + ); + + $result = wp_remote_post( $api_url, $args ); + + if ( is_wp_error($result) ) { + error_log( __CLASS__ . ': ' . $result->get_error_message() ); + } + + $body = json_decode( wp_remote_retrieve_body( $result ), true ); + if ( $body['status'] == 0 ) { + error_log( __CLASS__ . ': ' . print_r( $body, true ) ); + } + } +}
\ No newline at end of file |