Last active
December 20, 2015 01:29
-
-
Save lmayorga1980/6048949 to your computer and use it in GitHub Desktop.
Pushover notifications (Ruby/json)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Sends push over notifications using a json file that contains the user-keys and tokens | |
class Pushover | |
def initialize | |
json = File.read("json/pushover.json") | |
@users = JSON.parse(json)['users'] | |
@endpoint = "https://api.pushover.net/1/messages.json" | |
end | |
def send(message) | |
@users.each do |user| | |
`curl -s --cacert ca-bundle.crt -F \"token=#{user['token']}\" -F \"user=#{user['userkey']}\" -F \"message=#{message}\" #{@endpoint}` | |
end | |
end | |
end | |
###Json File | |
{ | |
"users": [ | |
{ | |
"token": "<your_token_here>", | |
"userkey": "<your_user_key_here>" | |
} | |
] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment