Last active
November 15, 2022 16:44
-
-
Save dtoki/1dae9eec72e0f1efb23ff3536b710391 to your computer and use it in GitHub Desktop.
Revisions
-
dtoki renamed this gist
Oct 7, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dtoki revised this gist
Oct 7, 2016 . No changes.There are no files selected for viewing
-
dtoki revised this gist
Oct 7, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,8 @@ function postDataToWebhook(data){ ] }; //register method called after data has been sent method is executed oReq.addEventListener("load", reqListener); oReq.open("POST", webHookUrl,true); oReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); -
dtoki created this gist
Oct 7, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ function postDataToWebhook(data){ //get the values needed from the passed in json object var userName=data.name; var userPlatform=data.platform; var userEmail=data.email; //url to your webhook var webHookUrl="webhook_url"; //https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest var oReq = new XMLHttpRequest(); var myJSONStr = payload={ "text": "Acuired new user", "attachments":[ { "author_name": userName, "author_icon": "http://icons.iconarchive.com/icons/noctuline/wall-e/128/Wall-E-icon.png", "color": "#7CD197", "fields":[ { "title":"Platform", "value":userPlatform, "short":true }, { "title":"email", "value":userEmail, "short":true } ] } ] }; //register method called after data has been sent method is executed oReq.addEventListener("load", reqListener); oReq.open("POST", webHookUrl,true); oReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); oReq.send(JSON.stringify(myJSONStr)); } //callback method after webhook is executed function reqListener () { console.log(this.responseText); }