Last active
August 29, 2015 13:56
-
-
Save kaugesaar/9346856 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
/* | |
* | |
* 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