Skip to content

Instantly share code, notes, and snippets.

@kaugesaar
Last active August 29, 2015 13:56
Show Gist options
  • Save kaugesaar/9346856 to your computer and use it in GitHub Desktop.
Save kaugesaar/9346856 to your computer and use it in GitHub Desktop.
/*
*
* Very basic Client Lib for Push.co
* Send Push notifications to your iPhone from AdWords Scripts
*
* @author Victor Kaugesaar, kaugesaar@gmail.com
* Version 1.0
*
* With inspiration from:
* http://www.freeadwordsscripts.com/2014/01/make-calls-and-send-text-messages-to.html
*
*/
function PushCo(apiKey, apiSecret) {
this.API_KEY = apiKey;
this.API_SECRET = apiSecret;
this.API_URL= 'https://api.push.co/1.0/push';
this.sendPushMessage = function(message) {
var headers = {
'method' : 'POST',
'payload': {
'message' : message,
'api_key' : this.API_KEY,
'api_secret' : this.API_SECRET,
},
};
http_post(this.API_URL,headers);
}
this.sendPushUrl = function(message,url) {
var headers = {
'method' : 'POST',
'payload' : {
'message' : message,
'url' : url,
'view_type' : 1,
'api_key' : this.API_KEY,
'api_secret' : this.API_SECRET,
},
};
http_post(this.API_URL,headers);
}
function http_post(url,headers) {
var response = UrlFetchApp.fetch(url,headers).getContentText();
return JSON.parse(response)['message'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment