Skip to content

Instantly share code, notes, and snippets.

@stammy
Created September 3, 2010 15:39
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 stammy/564058 to your computer and use it in GitHub Desktop.
Save stammy/564058 to your computer and use it in GitHub Desktop.
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