Skip to content

Instantly share code, notes, and snippets.

@lmayorga1980
Last active December 20, 2015 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmayorga1980/6048949 to your computer and use it in GitHub Desktop.
Save lmayorga1980/6048949 to your computer and use it in GitHub Desktop.
Pushover notifications (Ruby/json)
#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