Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sadortun/453aa1d390f1ce624113985f465f6a36 to your computer and use it in GitHub Desktop.
Save sadortun/453aa1d390f1ce624113985f465f6a36 to your computer and use it in GitHub Desktop.
// Simple spreadsheet, with first sheet containing form submission repsonses
// when the form is submitted:
// 1) grab the latest response,
// 2) post it to a third party service via an HTTP POST
function testWebhook() {
var ss = SpreadsheetApp.openById(SPREADSHEET_ID);
var form=ss.getSheets()[0];
var lr=form.getLastRow();
var el=form.getRange(lr,2,1,1).getValue();
var t=el;
//The following escape palaver is gleaned from a Google help forum...
var p="val1="+encodeURIComponent(t).replace(/%20/g, "+")+"&val2="+encodeURIComponent(form.getRange(lr,3,1,1).getValue()).replace(/%20/g, "+");
// Here's where we do the callback...
var x=UrlFetchApp.fetch('http://www.postbin.org/YOURPASTEBINID',{method: 'post', payload: p});
}​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment