diff --git a/IO2013/YouTubeAnalytics/oauth2.gs b/IO2013/YouTubeAnalytics/oauth2.gs index 8481a51..9da9a28 100644 --- a/IO2013/YouTubeAnalytics/oauth2.gs +++ b/IO2013/YouTubeAnalytics/oauth2.gs @@ -1,4 +1,3 @@ - var AUTHORIZE_URL = 'https://accounts.google.com/o/oauth2/auth'; //step 1. we can actually start directly here if that is necessary var TOKEN_URL = 'https://accounts.google.com/o/oauth2/token'; //step 2. after we get the callback, go get token @@ -43,7 +42,7 @@ function getUrlFetchOptions() { function attemptTokenRefresh_() { var refreshToken = UserProperties.getProperty(refreshTokenPropertyName); if (!refreshToken) { - Logger.log('No refresh token available to refresh with ' + tokenKey); + Logger.log('No refresh token available to refresh with ' + refreshTokenPropertyName); return false; } var requestData = { @@ -115,4 +114,4 @@ function isTokenPresent_() { return false; } return true; -} \ No newline at end of file +} diff --git a/SAP/Forms/Code.gs b/SAP/Forms/Code.gs new file mode 100644 index 0000000..47f2236 --- /dev/null +++ b/SAP/Forms/Code.gs @@ -0,0 +1,51 @@ +function onFormSubmit(e) { + var myObject = {}; + var itemResponses = e.response.getItemResponses(); + for (var j = 0; j < itemResponses.length; j++) { + var itemResponse = itemResponses[j]; + myObject[itemResponse.getItem().getTitle()] = itemResponse.getResponse(); + //Logger.log('"%s" was "%s"',itemResponse.getItem().getTitle(), itemResponse.getResponse()); + } + + Logger.log(myObject); + + var t = HtmlService.createTemplateFromFile('product_template'); + t.data = myObject; + var postPayload = t.evaluate().getContent(); + + Logger.log(postPayload); + + var base_url = "https://sapes1.sapdevcenter.com/sap/opu/odata/IWBEP/GWDEMO/ProductCollection"; + var additionParams = "$format=json"; + var user = 'YOUR_USERNAME'; + var password = 'YOUR_PASSWORD'; + var header = 'Basic '+Utilities.base64Encode(user+':'+password); + + var headers = { + Authorization: header, + 'X-CSRF-Token' : 'Fetch', + "Content-Type": "application/atom+xml" + } + + + //Logger.log(headers); + var response = UrlFetchApp.fetch(base_url,{headers: headers, muteHttpExceptions: true}); + var csrf_token = response.getAllHeaders()['x-csrf-token']; + var cookie = response.getAllHeaders()['set-cookie']; + + //Logger.log(response.getAllHeaders()); + + headers['X-CSRF-Token'] = csrf_token; + headers['Cookie'] = cookie.join('; '); + + + + Logger.log(headers); + + //var deleteResponse = UrlFetchApp.fetch(id,{headers: headers, method : 'DELETE', muteHttpExceptions: true}); + + + var createResponse = UrlFetchApp.fetch(base_url,{headers: headers, method : 'POST', contentType : "application/atom+xml", payload: postPayload, muteHttpExceptions: true}); + + Logger.log(createResponse.getContentText()); +} diff --git a/SAP/Forms/product_template.html b/SAP/Forms/product_template.html new file mode 100644 index 0000000..7d56b01 --- /dev/null +++ b/SAP/Forms/product_template.html @@ -0,0 +1,24 @@ + + + + +Regular VAT +ARUN- +MTR +500.00 +4.200 +0.320 +0100000000 + +Notebooks +1 +EA +PR +KGM +SAP +EUR +0.040 +0.210 + + + \ No newline at end of file diff --git a/SAP/Gmail Schemas/Code.gs b/SAP/Gmail Schemas/Code.gs new file mode 100644 index 0000000..74fb569 --- /dev/null +++ b/SAP/Gmail Schemas/Code.gs @@ -0,0 +1,6 @@ +function testSchemas() { + var htmlBody = HtmlService.createHtmlOutputFromFile('mail_template').getContent(); + + GmailApp.sendEmail(Session.getEffectiveUser().getEmail(),'Alert for SAP - ' + new Date(),'', + {htmlBody: htmlBody}); +} diff --git a/SAP/Gmail Schemas/mail_template.html b/SAP/Gmail Schemas/mail_template.html new file mode 100644 index 0000000..4864715 --- /dev/null +++ b/SAP/Gmail Schemas/mail_template.html @@ -0,0 +1,45 @@ + + + + + +

+ This a test for a Go-To action in Gmail. +

+ + \ No newline at end of file diff --git a/SAP/README.md b/SAP/README.md new file mode 100644 index 0000000..0b89520 --- /dev/null +++ b/SAP/README.md @@ -0,0 +1,16 @@ +SAP Demos +================ + +Sample SAP integrations. You'll need to create a [sample SAP account](http://scn.sap.com/docs/DOC-40986) at the SCN. + +You can watch the video of the [sample demos here](http://www.slideshare.net/SAPAppsPartner/tehcnical-webinar-technical-webinar-building-mashups-with-google-apps-and-sap-using-sap-netweaver-gateway) (start at about 1 hr in for Google Apps demos) + +These are not official Google samples. These are more of proof of concepts to support demos and other presentations. + +Please use this code as a guidline and not as production ready code. + +http://developers.google.com/apps-script + +http://script.google.com + +All code in this folder released under [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0). diff --git a/SAP/Sheets/Code.gs b/SAP/Sheets/Code.gs new file mode 100644 index 0000000..6e6055f --- /dev/null +++ b/SAP/Sheets/Code.gs @@ -0,0 +1,174 @@ +//sample instance +//http://scn.sap.com/docs/DOC-40986 + + +function onOpen(){ + SpreadsheetApp.getActiveSpreadsheet() + .addMenu('SAP NetWeaver',[{name:'SAP Data Wizard', functionName:'showUI'}, + null, + {name:'Load Business Partners', functionName:'getBusinessPartnerData'}, + {name:'Load Sales Orders', functionName:'getSalesOrderData'}, + null, + {name:'Load Items for Sales Order', functionName:'loadSalesItems'}, + null, + {name: 'Post to Google+', functionName:'googleplus'}]);//future ideas +} + +function showUI(){ + var ui = HtmlService.createTemplateFromFile('ui').evaluate().setSandboxMode(HtmlService.SandboxMode.NATIVE).setHeight(550); + + SpreadsheetApp.getActiveSpreadsheet().show(ui); +} + +function returnDate(unix_timestamp){ + //var unix_timestamp = '1370025951'; + var date = new Date(unix_timestamp*1000); + //Logger.log(date); + return date; +} + +function returnUnixtimestamp(dateString){ + //var dateString = '2013-04-01'; + var parts = dateString.match(/(\d+)/g); + var date = new Date(parts[0], parts[1]-1, parts[2]); // months are 0-based + var timestamp = date.getTime()/1000 + ''; + return timestamp; +} + + +function createOrSetActiveSheet(sheetName){ + var ss = SpreadsheetApp.getActiveSpreadsheet(); + var sheets = ss.getSheets(); + var sheet; + for(var i = 0;i + + + + + + +SAP NetWeaver + +
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+ + +
+
+ + + diff --git a/Twilio/MakePhoneCall/MakePhoneCall.gs b/Twilio/MakePhoneCall/MakePhoneCall.gs index b4f866e..66cc6bd 100644 --- a/Twilio/MakePhoneCall/MakePhoneCall.gs +++ b/Twilio/MakePhoneCall/MakePhoneCall.gs @@ -19,7 +19,7 @@ function readRows() { function makePhoneCall(name,number, message){ //URL is the callback to the current service with the message - var url = ScriptApp.getService() + '?MSG'+message.replace(/ /g,'+'); //can't seem to send = in here + var url = ScriptApp.getService().getUrl() + '?MSG'+message.replace(/ /g,'+'); //can't seem to send = in here Logger.log(url); var payload = { "From" : "2246773902"