Created
September 3, 2010 15:39
-
-
Save stammy/564058 to your computer and use it in GitHub Desktop.
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
function sendNotifo(label,msg,uri) { | |
var https = new XMLHttpRequest(); | |
var creds = localStorage.getItem("notifo"); | |
var auth = "Basic " + Base64.encode(creds); | |
var push = 'to=' + encodeURIComponent(creds[0]) + '&msg=' + encodeURIComponent(msg) + '&uri=' + encodeURIComponent(uri) + '&label=' + encodeURIComponent(label) + '&title=' + encodeURIComponent("Page"); | |
https.onreadystatechange = function() { | |
if (this.readyState == 4) | |
switch (https.status) { | |
case 200: | |
document.getElementById('message').innerHTML = "<strong>Success</strong>: Your Notifo username and API key are valid."; | |
toggy('message'); | |
break; | |
default: | |
document.getElementById('notice').innerHTML = "<strong>Error</strong>: " + JSON.parse(https.responseText)['response_message']; | |
toggy('notice'); | |
break; | |
} | |
}; | |
https.open('POST', 'https://api.notifo.com/v1/send_notification', true); | |
https.setRequestHeader('Authorization', auth); | |
https.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
https.send(push); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment