New Google Script for Williams-Sonoma to show loc based on ip
This commit is contained in:
1
Scripts/GAS_GS/WSonoma_ip_location/.clasp.json
Normal file
1
Scripts/GAS_GS/WSonoma_ip_location/.clasp.json
Normal file
@ -0,0 +1 @@
|
||||
{"scriptId":"1WwqAt0owPBYtVHUoP0x1vMKrMhXPysWRxJ8qObWjb8qz87zV7HikjvYK","rootDir":"/Users/normrasmussen/Documents/Work/Scripts/GAS_GS/WSonoma_ip_location"}
|
||||
7
Scripts/GAS_GS/WSonoma_ip_location/appsscript.json
Normal file
7
Scripts/GAS_GS/WSonoma_ip_location/appsscript.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"timeZone": "America/New_York",
|
||||
"dependencies": {
|
||||
},
|
||||
"exceptionLogging": "STACKDRIVER",
|
||||
"runtimeVersion": "V8"
|
||||
}
|
||||
24
Scripts/GAS_GS/WSonoma_ip_location/getIPsgetLocation.js
Normal file
24
Scripts/GAS_GS/WSonoma_ip_location/getIPsgetLocation.js
Normal file
@ -0,0 +1,24 @@
|
||||
function getIpAddresses() {
|
||||
var sheet = SpreadsheetApp.getActiveSheet();
|
||||
var lastRow = sheet.getLastRow()-1;
|
||||
var dataRange = sheet.getRange(2, 5, lastRow, 1);
|
||||
var values = dataRange.getValues();
|
||||
for (data in values) {
|
||||
var address = values[data].toString();
|
||||
var accessKey = ''
|
||||
var api_url = 'https://api.ipstack.com/'+address+'?access_key='+accessKey
|
||||
const settings = {
|
||||
async: true,
|
||||
crossDomain: true,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
'X-Api-Key': apiKey
|
||||
}
|
||||
};
|
||||
const sendMsg = UrlFetchApp.fetch(api_url, settings);
|
||||
var uuidResponse = sendMsg.getContentText();
|
||||
var parsedata = JSON.parse(uuidResponse);
|
||||
Logger.log(parsedata);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user